I'm trying to generate migration scripts in EF6. However, due to EF6's shortcomings I need to call some of SQL manually. It looks like this:
public override void Up()
{
// ...
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("<name>.sql")
{
var reader = new StreamReader(stream);
string sql = reader.ReadToEnd();
this.Sql(sql);
}
}
When I'm doing migrations with Update-Database, it generally works as intended. However, the problem shows when I'm trying to generate migrations as scripts. Upon calling:
Update-Database -Script -SourceMigration <name> -TargetMigration <name>
Entity Framework:
- Correctly generates SQL resulting from the code in the migration (
CreateTableetc.) - Correctly generates first line of the custom SQL to the output script
- Dumps rest of the custom SQL to the Package Manager window.
How can I solve this problem, so that the full migration script is generated to the output file?