Entity framework Core Update-database specific migration

做~自己de王妃 提交于 2019-12-31 17:38:23

问题


I am trying to figure out how to run a specific migration from the package manager in nuget.

I have tried to run:

 update-database -TargetMigration test32

But I do get this message:

A parameter cannot be found that matches parameter name 'TargetMigration'.

I read about that command from Microsoft's documentation to a previous ef version.

So I am not sure how it is in ef core.


回答1:


According to EF Core Docs, correct parameter name is -Target (for EF Core 1.1) or -Migration (for EF Core 2.0)

so in your case:

update-database -target test32

or

update-database -migration test32

"Modern" way is to use "regular" command prompt and .NET Core CLI, and command like dotnet ef database update <target>




回答2:


The best answer given by Dmitry is a bit incorrect. There's no parameter -Target. The only parameter that can be applied is -Migration. Therefore, the right answer is:

Update-Database -Migration test32


来源:https://stackoverflow.com/questions/40783055/entity-framework-core-update-database-specific-migration

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