简体   繁体   中英

Entity FrameWork 6.1:change migration code generation template?

I need that change clustered index to another column and I found a solution for this change clustered index to another column .in my solution I must modify generated migration code like

.PrimaryKey(t => t.Id) 

To

.PrimaryKey(t => t.Id, null, true)

Is there any way that I do it automatically and I don't need modify migration?

Unfortunately there is currently no way to do this. See the comments in the following ADO.NET Blog post.

http://blogs.msdn.com/b/adonet/archive/2014/02/11/ef-6-1-0-beta-1-available.aspx

Specifically:

Rowan Miller 19 Feb 2014 3:37 PM

@Cragun & @redfearnk - At this stage you need to make the primary key index non-clustered by editing migration code. You could either do this by editing the scaffolded migration that creates the table to specify 'clustered = false' in the Index call for the primary key, or by manually adding code to change the index in a later migration.

In the future we may allow you to add an Index attribute to the key property to change the index that gets generated by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM