Question

I'm using the TPH (Table per Hierarchy) technique to map a set of entities.

DB Schema: UserGroupLabelSpreads table having a "UserId", "GroupId" and "LabelId" nullable fields with some additional common fields.

DAL Objects: - UserGroupLabelSpread abstract class. - UserSpread with a discriminator having only non-null UserId. - GroupSpread with a discriminator having only non-null GroupId. - LabelSpread with a discriminator having only non-null LabelId.

I've managed to get this thing to work, but when I try to connect the UserSpread entity to an existing "User" entity, I'm getting the following error: Error 1 Error 3034: Problem in Mapping Fragments starting at lines 487, 554: Two entities with different keys are mapped to the same row. Ensure these two mapping fragments do not map two groups of entities with overlapping keys to the same group of rows.

I've digged around to understand that the problem is that I'm mapping the UserId column twice: once for the discriminator condition and second for the association.

Am I right with my assumption? -Can I get this thing to work?

Thanks, Nir.

Was it helpful?

Solution

There is an updated version of EDM Generator which should be able to help you. You can use it to generate, validate and more. Sorry, got the wrong link. Here is the one to v2. I believe I've had this issue. If I am not mistaken it was due to me mapping the forreign keys wrong. I was however using beta 1 of EF4 at that time and some of the messages was wrong due to the proxies. Check your forreign keys. Blog.Id ---> Blog_id was my issue. I had Blog.Id --> Blog.Id and then BlogEntry.Id ----> Blog.Blog_Id which of course doesn't work but the designer is kind of unforgiving when it comes to mapping keys.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top