Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properties referred by the Principal Role App must be exactly identical to the key of the EntityType

I'm using EF DB first.

I have made a view.

Mapped it to EF.

Now I get the following error:

Error 2 Error 111: Properties referred by the Principal Role App must be exactly identical to the key of the EntityType MaMDBModel.App referred to by the Principal Role in the relationship constraint for Relationship MaMDBModel.FK_AppsData_App. Make sure all the key properties are specified in the Principal Role. D:\MaM\Dev\MamAdmin_1.0\MaMDBEntityFramework\MaMModel.edmx 768 11 MaMDBEntityFramework

this is my edmx:

http://ge.tt/3rRWTOR/v/0?c

like image 576
Elad Benda Avatar asked Nov 11 '12 13:11

Elad Benda


2 Answers

There is an error message as comment in your edmx file:

<!--Errors Found During Generation:
warning 6002: The table/view 'MamDB.dbo.VW_APPSDATA' does not have a primary key
defined. The key has been inferred and the definition was created as a read-only
table/view.
-->

The key that EF has inferred is probably wrong. According to the message you should define a primary key for your view in the database.

like image 60
Slauma Avatar answered Oct 07 '22 19:10

Slauma


A fairly old question, but still relevant today so I thought I'd share my 2 cents. If the re-mapping the relationship between two tables is proving to be more trouble than it's worth (as was my case), you might try deleting the problem tables from the EDMX, saving, then re-adding them to the EDMX again.

like image 41
Jason Sultana Avatar answered Oct 07 '22 20:10

Jason Sultana