+1  A: 

they had the same issue on the msdn forum (http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/fa618214-ad3d-42fc-8506-21d539aa2cb3)

check out the answer there, probably some extra stuff in your model which should not be there. can you post the edmx file?

Guy Wouters
A: 

I just had this happen to me as well.

The problem turned out to be an association with end-keys, which were not all part of the primary key for that entity!

For instance, deep within my .edmx I had this association:

<AssociationSetMapping Name="Table1Table2" TypeName="MyModel.Table1Table2" StoreEntitySet="Table2">
    <EndProperty Name="Table1">
        <ScalarProperty Name="Table1Key" ColumnName="Table1Key" /></EndProperty>
    <EndProperty Name="Table2">
        <ScalarProperty Name="Table2Key" ColumnName="Table2Key" />
        <ScalarProperty Name="Table2OtherColumn" ColumnName="Table2OtherColumn" />
</EndProperty></AssociationSetMapping>

and the definition of Table2 looks like this:

<EntityType Name="Table2">
    <Key>
        <PropertyRef Name="Table2Key" />
    </Key>
    <Property Name="Table2Key" Type="int" Nullable="false" />
    <Property Name="Table2OtherColumn" Type="int" Nullable="false" />
    ...other properties...
</EntityType>

Notice that Table2OtherColumn is in the EndProperty, but is not part of the actual key. Removing it from the EndProperty fixed the problem.

Note that Entity Framework 4 (Visual Studio 2010) can detect this problem at compile-time. Thus, if you are having serious trouble tracking down what table/property is causing this, just load your project into VS 2010 Express (after backing it up!) and try to compile.

BlueRaja - Danny Pflughoeft