My Software Notes

Useful things I discover

Entity Framework 1.0 (aka 3.5) – Problem in Mapping Fragments

leave a comment »

I have an Entity Framework 1.0 (aka 3.5) project (I wish we could upgrade to 4) and I recently got this error:

Problem in Mapping Fragments starting at lines 1987, 2308: Non-Primary-Key column(s) [ColumnBlah] 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.

It turns out it was caused because the person who created the table didn’t put a foreign key constraint on the column and so I had to add one.  When I updated the EF model it saw the constraint and added the corresponding navigation property to the entities BUT it kept the original scalar property and was still mapping it to the table column.  So now I had a property in an entity mapped to a column in the underlying table AND a navigation property mapped to the same column.

Simple solution: I deleted the scalar property from the entity.

Hope that helps someone.

 

Advertisements

Written by gsdwriter

November 19, 2010 at 6:15 am

Posted in Entity Framework

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: