"Problem with mapping fragments" error in Entity Framework. Please assist me in comprehending the causes of this mistake.



Error 3007: Problem in Mapping Fragments starting at lines 186, 205: Non-Primary-Key column(s) [WheelID] are being mapped in both fragments to different conceptual side properties - data inconsistency is possible because the corresponding conceptual side properties can be independently modified.

I found several places on the web describing this error, but I simply don't understand them. (confused smiley goes here)


There is something pretty fundamental here, I must be missing. Can you explain it, so that I understand it? Maybe using my real life example below?

alt text

Foreign key 1:N Wheels.Id -> Slices.WheelId

I add them to entity framework, and WheelId is not visible in the Slices-entity.

alt text

Doing some workaround (deleting the relationship from the db before adding tables to EF - then re-creating it and updating EF) I managed to get the WheelId to stay in Slices, but then I get the error mentioned at the top.

3/23/2019 5:59:35 PM

Accepted Answer

Since Slices.WheelId is an FK, you cannot expose it in your client model, period. There are ways to get the value, though.

var wheelId = someSlice.Wheels.ID;

Update In EF 4 you can do this by using FK Associations instead of independent associations.

8/21/2010 3:29:17 PM

Popular Answer

Try to remove foreign property column from Entity set using entity model design it will solve your problem

For example

We have two tables one is customer and other one is order, using entity model design we added association between customers and orders when we do this Ado.net entity framework i will add navigation properties to both below tables.

Like Customer.Orders - Here order is list Order.Customer

One - Many relation.

So we need to remove property from with name CustomerId[Foreign key column] from Order entity set.

For reference:


Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow