无法使用.Net核心模板配置MySql连接

问题描述:

我与MySql数据库的连接有问题。我使用目标版本.NET Framework 4.6.1生成了带有ASP.NET Core的应用程序。无法使用.Net核心模板配置MySql连接

我的连接字符串如下所示:

"ConnectionStrings": { 
    "Default": "server=localhost;port=xxxx;database=MmpDb;user=user;password=***;" }, 

我加MySql.Data.Entities参考Mmp.EntityFrameworkCoreMmp.Web.Host

我覆盖EF的DbContext:

public class MmpDbConfiguration : DbConfiguration 
    { 
     public MmpDbConfiguration() 
     { 
      SetDefaultConnectionFactory(new MySql.Data.Entity.MySqlConnectionFactory()); 
      SetProviderServices("MySql.Data.MySqlClient", 
       new MySqlProviderServices()); 
     } 
    } 

当我运行命令dotnet ef database update我得到一个错误,Keyword not supported: 'port'.

有人可以为此问题提供解决方案吗?

谢谢

由于实体框架核心是新的,没有太多成熟的驱动程序。 我建议你为MySql连接使用Pomelo.EntityFrameworkCore.MySql。

然后,删除所有迁移文件,因为它们会再次生成MsSql。 然后使用Add-Migration命令重新生成迁移文件,它应该可以工作。

你也可以在这里检查ABP的github仓库的相关问题https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2267