You can customize the generated code by sub-classing the CSharpMigrationCodeGenerator
class:
class MyCodeGenerator : CSharpMigrationCodeGenerator
{
protected override void Generate(
DropIndexOperation dropIndexOperation, IndentedTextWriter writer)
{
dropIndexOperation.Table = StripDbo(dropIndexOperation.Table);
base.Generate(dropIndexOperation, writer);
}
// TODO: Override other Generate overloads that involve table names
private string StripDbo(string table)
{
if (table.StartsWith("dbo."))
{
return table.Substring(4);
}
return table;
}
}
Then set it in your migrations configuration class:
class Configuration : DbMigrationsConfiguration<MyContext>
{
public Configuration()
{
CodeGenerator = new MyCodeGenerator();
}
}