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

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

问题描述

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天全站免登陆