Is there an equivalent to $ InitialDatabase when using ScriptUpdate?
The Update-Database EF Migration command accepts the following parameters: - Script -SourceMigration $ InitialDatabase. The script generated is idempotent as described 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?
+3
source to share
1 answer
I was struggling with the same too, but it turns out you just need to provide a "0".
Function example:
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);
+3
source to share