Entity Framework


In a project using Entity Framework, I received the error:

Error 111: Properties referred by the principal role MyTable must be exactly identical to the key of the entitytype when you compile the project in Visual Studio.

Entity Framework Resolution

I had two existing tables in the edmx diagram.

To create a relationship:

I had to make my identity field a primary key.  I then added the relationship.

In the entity framework diagram, I deleted and re-added the foreign table.

However, I did not delete/re-add the table with the new primary key.

Then, re-add the foreign table.

Next, Visual Studio added the relationship.  The problem is that it builds a relationship to a table that thought did not have a primary key.

When I deleted/re-added the primary key table from the diagram, the error resolved.


For more information on how Acumen can help you, contact us today!

For additional help, contact Microsoft Support by clicking on the link below: