I have two tables: <subjects>
and <prerequisites>
. The primary key of prerequisite table is a composite key: pr_subject_id
and pr_prerequisite_subject_id
. They are both foreign keys from the <subjects>
table. I can map the pr_subject_id in a association but i can't map the return trip (pr_prerequisite_subject_id
). See image. How should i solve this?
note: When i made the associations in sql server it was fine but when i loaded the database in the entity framework, the entity framework dropped the prerequisite table because of this return trip association.
I looked around but i think this is a common problem with the Entity Framework. I found two workarounds here. Basically what i did was adding a third column er_id and let that be the primary key. Then to enforce that there will be no double of the other two columns i added a unique constraint.