0

I have these three tables inside my sql server but when mapping these tables using EF I will lose the table representing the M-M relation -the accountsitemapping table- and in this case I will not be able to know which accounts are linked to which sites.
To workaround this problem I just added a new column to the AccountSiteMapping table and I re-mapped the tables again then I can access the AccountSiteMapping table.

enter image description here

But is there a way to be able to solve this problem without the need to modify my table design ?

mmmmmm
  • 31,464
  • 27
  • 87
  • 113
John Peter
  • 1,009
  • 4
  • 14
  • 27
  • The accepted answer to http://stackoverflow.com/questions/6070554/explicit-many-to-many-join-table-in-entity-framework-4 should have you good to go. – Faust Jan 05 '13 at 11:03

1 Answers1

1

By default entity framework will hide all mapping tables in many-to-many relationships. You will have to do your queries this way:

For example, finding SiteDefinitions associated with a given org_ID:

db.SiteDefinitions.Where(a => a.AccountDefinitions.Any(b => b.ORG_ID == org_ID));
rexcfnghk
  • 12,915
  • 1
  • 31
  • 55
  • You can read [here](http://smehrozalam.wordpress.com/2010/06/29/entity-framework-queries-involving-many-to-many-relationship-tables/) for more info. – rexcfnghk Jan 05 '13 at 11:06