Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF - Generate script from previous migration

I want to update database schema on production database. Usually in my development I just do Add-Migration and Update-Database.

My question is how to generate script so I can manually read through the query before executing in production environment? I've tried Update-Database -script but it gave me No pending explicit migrations.

like image 525
warheat1990 Avatar asked Feb 03 '16 03:02

warheat1990


1 Answers

Try running:

Update-Database -Script -SourceMigration: <initial-migration> -TargetMigration: <latest-migration>

Obviously replace <initial-migration> and <latest-migration> with the appropriate names of those migrations.

That should generate a script of all migrations at once.

More information can be found here on MSDN.

like image 184
Alex Avatar answered Sep 28 '22 07:09

Alex