Reputation: 9013
I have 3 simplest tables:
http://magicscreenshot.blob.core.windows.net/screenshots/udYWngOVQEM.jpg
and relationships among them:
http://magicscreenshot.blob.core.windows.net/screenshots/zTK28gBgkEc.jpg
If I create a new project from zero and create Entity Model (from DB) I receive correct EF model:
http://magicscreenshot.blob.core.windows.net/screenshots/ZZg8gpzXFkE.jpg
But when I try to do the same for my real project - created EF model is very strange
http://magicscreenshot.blob.core.windows.net/screenshots/WfKgc8vBDU8.jpg
as we can see, it created a new entity "SectionSite" with relationship to Site and no relationship to Section. Why it happened and how to fix it?
Upvotes: 1
Views: 42
Reputation: 332
I was able to replicate this if you added in your Section and SectionSite table independently of adding your Site table. This creates the link the following link.
To resolve this missmatch of identity you can either.
OR
Upvotes: 1
Reputation: 1742
With Entity Framework you don't have to create a mapping table.
If you let your Section refer to multiple Sites (ICollection) and let your Site refer to multiple Sections (ICollection), Entity Framework will create a SectionSite or SiteSection table for you.
Upvotes: 0