非主键字段的实体框架外键 [英] Entity Framework foreign keys to non-primary key fields

查看:33
本文介绍了非主键字段的实体框架外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Entity Framework 4.0 是否有可能具有基于非主键字段的外键的关联/导航属性(它具有唯一约束).

Is it possible for Entity Framework 4.0 to have an association/navigation property based off of a foreign key to a non-primary key field (it has a unique constraint).

推荐答案

否,因为 EF 还不了解唯一约束,并且 EF 中的关系必须遵循与数据库中的关系相同的规则.没有唯一主体关系就无法存在,在 EF 中获取唯一主体的唯一方法是使用主键.

No because EF don't understand unique constraint yet and relations in EF must follow same rules as relations in database. Without unique principal relation cannot exist and the only way to get unique principal in EF is using primary key.

这篇关于非主键字段的实体框架外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆