How to stop EF4.1 Code-First to create Culstered index for the entity PK

痴心易碎 提交于 2019-11-29 11:33:01

You don't need to predict name of auto generated index. You just need to select name of the index. For SQL server you can use query like:

SELECT I.Name
FROM sys.indexes AS I
INNER JOIN sys.tables AS T ON
    I.object_Id = T.object_Id
WHERE I.is_primary_key = 1 
    AND T.Name = 'Users'

Once you get the name in your custom initializer you can alter old index and create a new one.

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