What's “Entity key” in edmx file?

人走茶凉 提交于 2019-12-13 13:47:57

问题


in a C# project, using EF Database first I've added a foreign key to a table using SQL server management studio.

After that, back to Visual Studio I've updated the model from the database but I couldn't see the "link" (i.e. the line joining the two tables in the .edmx diagram) between the two affected tables. So in the dropdown over the child table I saw this option "Entity key" and when I clicked it the "link" appeared. To be honest, I don't know and I can't understand what it does, cause I can check or uncheck it now without losing the, again let's say "link".

Do you know why this behaviour?

Thanks!!


回答1:


EntityKey is the Entity idea of a Primary Key in a (SQL in your case) database. You should set it for any column that is a primary key, and then you can setup your Entity Associations to match your database associations.

Working with Entity Keys.

Setting correct EntityKeys is a must for getting correct results from SQL Server, because EntityKeys are used as an internal caching key.



来源:https://stackoverflow.com/questions/10138074/whats-entity-key-in-edmx-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!