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?
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