As part of planning an Entity Framework migration, in order to debug data movement, I would often use the -Script parameter to generate the script.
I could then take
This is working for me:
public class MigrationScriptBuilder : SqlServerMigrationSqlGenerator
{
public override IEnumerable Generate(IEnumerable migrationOperations, string providerManifestToken)
{
var statements = base.Generate(migrationOperations, providerManifestToken);
statements = statements.SelectMany(s => new[] {
s,
new MigrationStatement
{
Sql = "GO"
}
}).ToList();
return statements;
}
}
Which (as seen in other answers) can be used (migration process flow) with this kind of method in the DbContext Configuration:
public Configuration()
{
SetSqlGenerator("System.Data.SqlClient", new MigrationScriptBuilder());
}