views:

31

answers:

1

Hi,

In Entity Framework (VS2010) how do I create an association to/from the same table? (a many-to-many is what I want)

Background - I was expecting under the bonnet a NODE and RELATIONSHIP table, where the latter has a parent_node_id and a child_node_id (i.e. pointing back to the NODE id column). I can't seem to get the designer to add it...

+2  A: 

Model first: create entity, right click: add association, select same Entity, mark it Many to many on both ends.

Database first: create two tables: Node and Edge, Edge contains two Node references. (Using appropriate PK, FK's).

Hightechrider
thanks - seems to work at work, however wasn't at home before - I wonder if my VS2010 running under VMFusion was doing something funny - I'll try again tonight from home
Greg