How to get the database update script from the last migration?

.net .net-core asp.net-core ef-migrations entity-framework-core

Question

Today I'm using EF migrations in the following way: I use

dotnet ef migrations add MigrationName

to create a new migration, and then

dotnet ef database update

to apply the last update to the database.

Now, if I just want the last migration database update script to be generated is there a way using dotnet ef?

I mean, obviously before applying, the toolchain has to generate the script, which is then submited to the database.

Is there a way to just output the script without applying to the database?

1
0
3/3/2017 6:41:25 PM

Popular Answer

You can use

  dotnet ef migrations script -from (MigrationYouWant-1) -to MigrationYouWant

to create the SQL script (so basically everything is scripted between "from" and "to", "from" excluded and "to" included). You can find more info on the topic here:

https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet

3
3/3/2017 8:29:52 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