Entity Framework - Derived Object Association

I use the TPH method (table for hierarchy) to map a set of objects.

Database schema: UserGroupLabelSpreads table with fields "UserId", "GroupId" and "LabelId" with zero values ​​with some additional common fields.

DAL objects: - abstract class UserGroupLabelSpread. - UserSpread with discriminator having only nonzero UserId. - GroupSpread with discriminator having only non-zero GroupId. - LabelSpread with discriminator having only non-zero LabelId.

I managed to get this work to work, but when I try to connect the UserSpread object to the existing User entity, I get the following error: Error 1 Error 3034: Problem while matching Fragments starting with lines 487, 554: two objects with different keys are displayed in the same line. Make sure that these two display fragments do not display two groups of objects with overlapping keys in the same row group.

I realized that the problem is that I map the UserId column twice: once for the discriminator condition and one for the association.

Am I right with my guess? -Can I make this work work?

Thanks, Nir.

+3
source share
1 answer

EDM Generator, . , .. , . v2. , . , . , - 1 EF4, - . forreign. Blog.Id --- > Blog_id . Blog.Id β†’ Blog.Id, BlogEntry.Id ---- > Blog.Blog_Id, , , , , .

+2

Source: https://habr.com/ru/post/1709941/


All Articles