Manually add a migration?

孤街醉人 提交于 2019-12-20 02:05:53

问题


I've been using Entity framework code first in a project and all the tables have been created /modified a while ago. Now I need to add an unique constraint to a table. I want to create a migration which will have the following row in the Up() method. And there is no change on the model classes.

CreateIndex("TableName", new[] { "Column1" }, true, "IX_UniqueKey");

And maybe the following row in the Down()

DropIndex("TableName", new [] { "Column1" });

Can I just manually create a file under the folder Migrations? And is there any mandatory file name convention?

How to create the .Designer.cs and .resx files? Or should I use add-migration with some parameters?


回答1:


Using add-migration is the way for this. Just use add-migration yourMigrationName and it will automatically create all the files you need.

Then you just alter the Up() and Down() methods with the values that you need



来源:https://stackoverflow.com/questions/22447331/manually-add-a-migration

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