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

ef-code-first entity-framework entity-framework-6 entity-framework-6.1

Question

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
0
7/25/2014 8:01:08 AM

Accepted Answer

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.

2
5/23/2017 12:23:47 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow