RSS

Tag Archives: entity framework; c#; designer

Entity framework 3.5 cryptic error: “Two entities with different keys are mapped to the same row…”

Just putting this out there might save someone some pain and time. I got the error after adding an association (one to many).

On comparing this association with another one that did not have an error, and on reading this<a href=”http://social.msdn.microsoft.com/Forums/en-US/c1e1d43a-a09f-4692-9372-3133f04d3eeb/error-3034-two-entities-with-different-keys-are-mapped-to-the-same-row”&gt; post</a>, it was clear that the entity designer did not add the all important line

<Condition ColumnName=”” IsNull=”false”/>;

see the entire associationsetmapping below. I deleted columnnames but in the snippet above the colulmn name is the actual db columnName (the ‘store’ model in EF – as opposed to the ‘conceptual’ model) of the primary key in the one side of the association
<AssociationSetMapping Name=”” TypeName=””; StoreEntitySet=”>
<EndProperty Name=””><ScalarProperty Name=”” ColumnName=”” /></EndProperty>
<EndProperty Name=””> <ScalarProperty Name=”” ColumnName=”” /></EndProperty>
<Condition ColumnName=”” IsNull=”false” />;
</AssociationSetMapping>

 

 
Leave a comment

Posted by on September 11, 2013 in software

 

Tags: