Entity Framework 6.1.3 Mapping Foreign key to non primary key

风流意气都作罢 提交于 2019-11-29 04:07:35

This is now possible in Entity Framework 7 (that is, EF Core 1.0).

From .Net Entity Framework User Voice Unique Constraint (i.e. Candidate Key) Support:

Support for this feature was added in EF Core 1.0 and we don’t have plans to add it in the EF6 codebase.

user2184057

I don't think it is possible cause it would cause a lot of trouble. Foreign key should should always point to some key of a table. I don't think you are able to tell EF about candidate keys.

Edit:

Similar Questions: Entity Framework 5.0 composite foreign key to non primary key - is it possible?

Here is answer for your question. As I thought EF does not understand the concept of uniqueness with exception of primary key.

Entity Framework foreign keys to non-primary key fields

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