实体框架代码优先 - 为此EntityType定义非群集密钥 [英] Entity Framework Code-First - Define the Non-clustered key for this EntityType
问题描述
的集群索引,但是当我将Index属性添加到我的时候收到一个错误模型,
有人可以告诉我如何定义一个非群集密钥?
AFAIK仍然无法创建非群集主键字段作为代码首次配置的一部分。
但是,如果您使用迁移或处于您可以的位置,请参阅使用代码首次迁移
的以下实体框架工作项, strong>(以及没有直接代码支持的思考):http://entityframework.codeplex.com/workitem/614
此相关问题也有一些信息:一个href =https://stackoverflow.com/questions/6813462/ef-codefirst-create-non-clustered-primary-key-index> EF CodeFirst创建非群集主键索引。它是EF 4.1,但仍然与EF 6相关。
I Have defined an entity class with a key, but I don,t want that key be cluster because I have another cluster index in my entity, but I received an error when I add an Index attribute to my model,
Can anybody tell me that how can I define a Non-Clustered Key????
AFAIK it is still not possible to create non-clustered primary key fields as part of your code first configuration.
However, if you are using migrations or are in a position where you are able to, see the following Entity Framework work item that goes through a solution using code first migrations (as well as the thinking behind no direct code first support):
http://entityframework.codeplex.com/workitem/614
This related question has some information as well: EF CodeFirst create non-clustered primary key index. It is for EF 4.1 but still relevant to EF 6.
这篇关于实体框架代码优先 - 为此EntityType定义非群集密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!