views:

37

answers:

1

When creating an entity framework model from scratch it is possible to specify a Many to Many relationship in the model.

e.g Entity1 * ----- * Entity2

When a database is then generated from this, a resolver table is then created automatically between the two entities, this is hidden in the code model, allowing direct access to each of the entities via properties.

e.g. Entity1 ----* ResolverEntity *----- Entity2

My question is, when a model is generated from an existing database, which contains resolver tables, is it possible to create the same effect so the resolver tables do not appear in the generated object model?

When I have attempted this, the entity framework appears to create entities in the model for the resolver tables with no obvious way of hiding them in the object model.

Thanks.

+1  A: 

Yes, provided that what you're calling the "resolver table" contains only two columns, FKs to Entity1 and Entity2, and that those two columns form a compound PK. In this case, the EF GUI designer will recognize the pattern and generate a many to many relationship. If your DB schema doesn't fit these constraints, you'd have to edit the EDMX by hand.

Craig Stuntz
Thanks, thats a great help.
grrrrrrrrrrrrr