Reputation: 1745
I have a database with two tables, customer and account. Because multiple customers can exist on multiple accounts this is a many to many design.
This is how I designed it in SQL
This works quite nicely as Entity Framework picks up that its a mapping table and just maps Customer to Account as lists on each and hiding the mapping table. Brilliant!
I would like to extend this further to add preferences to a mapping between a customer and an account like such:
Am I right in assuming this is not possible? I have tried adding it to EF model but instead it brings back the mapping table.
Anyone else had any luck with this?
Upvotes: 0
Views: 201
Reputation: 1496
What you have in your first case is a simple many to many relation table, which in Entity Framework results in the collections of entities on one another.
If you want to have a relation to the Preference
from your CustomerAccount
relation table, the relation becomes complex and it cannot be depicted in the simple relation lists anymore. You need add an entity for your relation CustomerAccount
which will have foreign keys on Customer
, Account
and Preference
.
Upvotes: 1