I have been working on the entity framework for a short span of time. My question is regarding savechanges() or rather what exactly is hapening in this scenario.

I have 3 tables: Container , subcontainer, innercontainer there is a 1-n relation between tables in the specified order. i have added used the AddObject() to add the objects into the context and i am calleing save changes at the end of it all. But wen i so that i get this following error: "Unable to determine the principal end of the FK relationship. Multiple added entities may have the same primary key". Now i guess what it is telling me is that there are a few objects that i have added with the same PK (EF takes 0 by default). and it shows me on the error on the innercontainer table. My question here is why does it show the error on the innercontiner but not on the subcontainer? (context will contain subcontiner with the same PK of 0).

Relevent Info:
- All PK is autogenerated in DB
- calling save changes after all addition because to increase performance (still a test)

2 Years
Discussion Span
Last Post by TekknoDraykko
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.