I have a production and a development database. Now I want to generate a sql script based on a specific migration. When I enter the line to generate the script I get this error:
'201608121243147_AutomaticMigration' is not a valid migration. Explicit migrations must be used for both source and target when scripting the upgrade between them.
The command I use is as follows:
Update-Database -Script -SourceMigration:201608121243147_AutomaticMigration -TargetMigration:201608281101542_AutomaticMigration
When I execute the command
get-migrations I can see those two migrations are in the list. The target migration is also my latest migration, but when I omit this parameter I get the same exception.
What am i doing wrong? What do I have to do to fix this?Answer1:
Try removing the semicolon after
SourceMigration and after
Update-Database -Script -SourceMigration 201608121243147_AutomaticMigration -TargetMigration 201608281101542_AutomaticMigrationAnswer2:
This works for me.
Update-DataBase -Script -SourceMigration:"Version1" -TargetMIgration:"Version2"