I'm building a MVC application with .Net Core and I need to generate the script of a migration.
With EF6 I did run the command
update-database -script
but when I try to do the same with .net Core is throwing the next exception:
Update-Database : A parameter cannot be found that matches parameter name 'script'
Do you know if there is an equivalent for EF7?
As per EF documentation you can use Script-Migration
command.
If you want to just script all the migrations you can simply call it from Package Manager console like that. If you want to just script the changes from the last migration you can call it like this:
Script-Migration -From <PreviousMigration> -To <LastMigration>
Be sure to check the docs, there're a few more options to the command.
You can use dotnet core cli to generate script
dotnet ef migrations script
Also you can put this to file with new power shell out-file
command.
dotnet ef migrations script | out-file ./script.sql