Bug #73278 | EF6 MySql Migrations Code Generator Bug, Broken Column Index Code | ||
---|---|---|---|
Submitted: | 11 Jul 2014 17:00 | Modified: | 5 Mar 2015 18:31 |
Reporter: | Ryan Mann | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.8.3.0 | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | codefirst, CodeGenerator, EF6, migrations, MySql.Data.Entity.EF6 |
[11 Jul 2014 17:00]
Ryan Mann
[11 Jul 2014 17:02]
Ryan Mann
Changed title to reflect what the bug is
[31 Aug 2015 9:54]
Oleg Savelos
This is still present in 6.9.7.0
[6 Jan 2016 13:29]
Aliaksei Kartynnik
This is still present in 6.9.8.0 version to...
[11 Jan 2016 13:32]
Stian Skjerveggen
For a simple fix, override GenerateInline(CreateIndexOperation, IndentedTExtwriter) from MysqlMigrationCodeGenerator like so: public class FixedMySqlMigrationCodeGenerator : MySql.Data.Entity.MySqlMigrationCodeGenerator { private string TrimSchemaPrefix(string table) { if (table.StartsWith("dbo.")) return table.Replace("dbo.", ""); return table; } protected override void GenerateInline(CreateIndexOperation createIndexOperation, IndentedTextWriter writer) { writer.WriteLine(); writer.Write(".Index("); Generate(createIndexOperation.Columns, writer); writer.Write(createIndexOperation.IsUnique ? ", unique: true" : ""); writer.Write(!createIndexOperation.HasDefaultName ? string.Format(", name: \"{0}\"", TrimSchemaPrefix(createIndexOperation.Name)) : ""); writer.Write(")"); } } Then use the new class as CodeGenerator in your migration Configuration constructor