I have one Courses table mapped to two Course and CourseDetails objects .
Both have POCO classes with virtual navigation properties .
Both objects use the same identifier (Identity on the course, but not on CourseDetail).
Mapping between objects is a " referential integrity constraint " not in the "mapping" window.
The course is a principle of limitation.
I am using LazingLoading and ProxyCreationEnabled .
After calling context.SaveChanges (), the connections look great (identifiers, links, and data).
When accessing the course. CourseDetails from the loop in context. Courses. I get empty CourseDetails fields created by the course constructor, instead of the actual CourseDetails !?
When I call context.LoadProperty (course, c => c.CourseDetails) I get an InvalidOperationException with the message:
" Multiplicity violation. The role of the 'CourseDetails' relationship 'OrmComparisons.EFPocos1.CourseDetailsCourse' has a multiplicity of 1 or 0..1. "
Question 1: Why is Course.CourseDetails empty?
Question 2: Why am I getting an exception?
Question 3: What should I do instead?
I can share the solution file + sql if someone wants to look.
source
share