The EF migrations Update-Database command accepts the following parameters: -Script -SourceMigration $InitialDatabase. The script generated is idempotent as explained in this article: http://msdn.microsoft.com/en-US/data/jj591621
Is there an equivalent parameter when using the ScriptUpdate method of the MigratorScriptingDecorator class?
I also struggled with the same, but it turns out you just have to provide "0".
Example function:
public static string CreateUpdateScript(DbMigrationsConfiguration config, string sourceMigration, string targetMigration)
{
var migrator = new DbMigrator(config);
var scripter = new MigratorScriptingDecorator(migrator);
return scripter.ScriptUpdate(sourceMigration, targetMigration);
}
Then call it like this:
CreateUpdateScript(new Configuration(), sourceMigration: "0", targetMigration: null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With