I have an issue which I could not find answer for across the web.
I am using CodeFirst EF 4.3.1 Migrations with MsSQL.
I have added several migrations and now I want to produce a script for upgrade/downgrade between two migrations.
For upgrade I run the following command which successfully reproduces an upgrade script:
PM> Update-Database -Script -SourceMigration:"201205161144187_AddPostAbstract" -TargetMigration:"201205161203310_BlogLimitsAndTableRename"
However, for downgrade I run the following command which fails with the following error:
PM> Update-Database -Script -SourceMigration:"201205161203310_BlogLimitsAndTableRename" -TargetMigration:"201205161144187_AddPostAbstract"
Scripting the downgrade between two specified migrations is not supported.
Any ideas how can I generate a downgrade script?
Thanks.
It looks like migration API expects that you want to do downgrade only from "last version".
If
BlogLimitsAndTableRename
is your most recent migration (the last applied) you can simply run:If it is not your last migration you need to revert your development database to it first:
and now you should be able to use the first command to get a script.