想知道 Entity Framework 5 是否支持对实体属性的唯一约束?如果是这样,我如何指定一个属性应该是唯一的?
Wondering if Entity Framework 5 supports unique constraints on entity properties? If so, how can I specify that a property should be unique?
推荐答案不,它没有.过去曾计划在 EF 5.0 中包含独特的约束功能:
No, it doesn't. There were plans in the past to include a unique constraint feature in EF 5.0:
blogs.msdn/b/efdesign/archive/2011/03/09/unique-constraints-in-the-entity-framework.aspx
但是你可以看到帖子顶部有一个更新:
But you can see that there is an update on top of the post:
更新:此功能已推迟,不会包含在实体框架 5.
Update: this feature has been postponed and will not be included in Entity Framework 5.
您可以对该功能进行投票,以提高其实施的优先级...
You can vote on the feature to raise possibly the priority it gets implemented with...
/data.uservoice/forums/72025-entity-framework-feature-suggestions/suggestions/1050579-unique-constraint-ie-candidate-key-support
...因为显然目前它甚至不在 EF 6.0 的路线图上:
...because apparently it isn't even on the roadmap for EF 6.0 at the moment:
entityframework.codeplex/wikipage?title=Roadmap
更多推荐
Entity Framework 5 是否支持唯一约束?
发布评论