How to set SetSqlGenerator and CodeGenerator in My

2019-04-29 16:48发布

I updated my MySql connector/net to 6.9.6 (from 6.9.5) and EF to 6.1.3 (from 6.1.2) which broke migrations :(

I used to have this, which would make migrations work on MySql.

public Configuration()
{
    // fails with cannot assign MySqlMigrationSqlGenerator toSystem.Data.Entity.Migrations.Sql.MigrationSqlGenerator
    SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());

    // fails with cannot assign MySqlMigrationCodeGenerator to System.Data.Entity.Migrations.Design.MigrationCodeGenerator
    CodeGenerator = new MySql.Data.Entity.MySqlMigrationCodeGenerator();
}

But now that doesn't work. And when I remove it the generated migrations are prefixed with dbo which doesn't work.

I tried setting the new config in the web.config

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">

also tried setting the new attribute on the context.

[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class MyContext : DbContext

But to no avail.

How do I make migrations work again with this new connector?

0条回答
登录 后发表回答