I have problems using the MigratorScriptingDecorator.ScriptUpdate in Entity Framework 4.3.1.
When specifying sourceMigration and targetMigration only my initial migration gets written, the rest of my migrations become empty.
I have entered a bug report on Microsoft Connect containing reproducing code.
https://connect.microsoft.com/VisualStudio/feedback/details/731111/migratorscriptingdecorator-in-entity-framework-migrations-does-not-respect-sourcemigration-and-targetmigration
I expect MigratorScriptingDecorator.ScriptUpdate("from", "to") to behave exactly like the corresponding PM command
PM> Update-Database -Script -SourceMigration from -TargetMigration to
Should ScriptUpdate be equivalent to Update-Database -Script?
Are there any other ways of generating update scripts from code?
As noted on the linked Microsoft Connect issue the problem was a reuse of the same
DbMigratoron severalMigratorScriptingDecorators.The original code was
the
MigratorScriptingDecoratorshould be instantiated outside the loop like this: