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

entity-framework

Question

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.

Numerous websites on the internet describe this problem, but I am unable to grasp them. (smiley with confusion)

One
Two
Three
Four

I must be missing something really basic here. Can you clarify it for me so I can comprehend it? maybe utilizing the example from my actual life below?

alt text

N Wheels.Id -> Slices is the first foreign key. WheelId

WheelId is not present in the Slices-entity even after I add them to the entity framework.

alt text

I was able to keep the WheelId in Slices by using a workaround (deleting the relationship from the database before adding tables to EF, then creating it again and updating EF), but then I started receiving the problem noted at the top.

1
49
3/23/2019 5:59:35 PM

Accepted Answer

Slices.WheelId cannot be exposed in your client model since it is an FK. But there are methods to get the value.

var wheelId = someSlice.Wheels.ID;

Update You may do this in EF 4 by utilizing FK Associations rather than independent associations.

43
8/21/2010 3:29:17 PM

Popular Answer

To address your issue, try removing the foreign property column from the entity set using entity model design.

For instance

We have two tables, customer and order, and we established associations between customers and orders using entity model architecture. When we complete this using Ado.net entity framework, I will add navigation properties to both of the following tables.

Similar to Customer.Orders, here's an order list for Customers.Order.

One-to-many relationship

Therefore, we must delete the property from the Order entity set with the name CustomerId[Foreign key column].

For information:

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/2823634f-9dd1-4547-93b5-17bb8a882ac2/



Related Questions





Related

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