C# 如何为EF 6.4和MySQL C启用迁移?
我尝试使用命令启用迁移 启用迁移 但我得到了下面的错误,我真的不知道如何解决它 我安装了所有的扩展以使其正常工作。 错误消息:C# 如何为EF 6.4和MySQL C启用迁移?,c#,mysql,entity-framework-6,migration,entity-framework-migrations,C#,Mysql,Entity Framework 6,Migration,Entity Framework Migrations,我尝试使用命令启用迁移 启用迁移 但我得到了下面的错误,我真的不知道如何解决它 我安装了所有的扩展以使其正常工作。 错误消息: Checking if the context targets an existing database... No MigrationSqlGenerator found for provider 'MySql.Data.MySqlClient'. Use the SetSqlGenerator method in the target migrations con
Checking if the context targets an existing database...
No MigrationSqlGenerator found for provider 'MySql.Data.MySqlClient'. Use the SetSqlGenerator method in the target migrations configuration class to register additional SQL generators.
我假设您的项目是一个.net核心应用程序,并且您使用的是visual studio
正如错误消息所说,您需要首先更改MigrationSqlGenerator。 您可以通过两种方式完成: 修改App.Config中的entityFramework部分
<entityFramework codeConfigurationType="MyNamespace.MyDbConfiguration, MyAssembly">
...Your EF config...
</entityFramework>
对于MySql.Data.Entity->MySql.Data(>=6.10.9)
对于MySql.Data.EntityFramework->MySql.Data(>=8.0.20)
[DbConfigurationType("MyNamespace.MyDbConfiguration, MyAssembly")]
public class MyContextContext : DbContext
{
}
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
...other providers
</providers>
</entityFramework>
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6))]
public class DemoContext : DbContext
{
}
<entityFramework codeConfigurationType="MySql.Data.EntityFramework.MySqlEFConfiguration, MySql.Data.EntityFramework">
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
...other providers
</providers>
</entityFramework>
[DbConfigurationType(typeof(MySql.Data.EntityFramework.MySqlEFConfiguration, MySql.Data.EntityFramework))]
public class DemoContext : DbContext
{
}