Entity Framework Code-First - Define the Non-clustered key for this EntityType

百般思念 提交于 2019-12-08 13:42:51

问题


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????


回答1:


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.



来源:https://stackoverflow.com/questions/24924752/entity-framework-code-first-define-the-non-clustered-key-for-this-entitytype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!