poniedziałek, 18 stycznia 2010

EntityFramework and many to many relation

Today I'm going to share my thoughts about many to many relationship, when working with EntityFramework. Let's assume that we have datatables like shown below:
As we can see in the picture we have many customers, that can have many projects, but when we make this association we would like to know save additional information about AmountSpent and PerComplete.
This kind of mapping in entity framework will result in 3 tables in entity datamodel, opposite to situattion when association table contains only references ids - then we have only two objects in entity datamodel. What's important you have to make primary key in mapping table as combination of referenced identifiers.