Bạn có thể thực hiện điều này bằng cách mở rộng MySqlMigrationSqlGenerator như sau:
/// <summary>
/// Custom MigrationSqlGenerator to add semi-colons to the end of
/// all migration statements.
/// </summary>
public class CustomMySqlMigrationSqlGenerator : MySqlMigrationSqlGenerator {
public override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken) {
IEnumerable<MigrationStatement> statements = base.Generate(migrationOperations, providerManifestToken);
foreach (MigrationStatement statement in statements) {
if (!statement.Sql.EndsWith(";")) {
statement.Sql = statement.Sql.TrimEnd() + ";";
}
}
return statements;
}
}
Và kích hoạt nó trong Configuration.cs
:
public Configuration() {
AutomaticMigrationsEnabled = false;
SetSqlGenerator("MySql.Data.MySqlClient", new CustomMySqlMigrationSqlGenerator());
}