实体框架非主键字段的外键

问题描述:

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.