2017-07-31 75 views
0

我與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'.

有人可以爲此問題提供解決方案嗎?

謝謝

回答

1

由於實體框架核心是新的,沒有太多成熟的驅動程序。 我建議你爲MySql連接使用Pomelo.EntityFrameworkCore.MySql。

然後,刪除所有遷移文件,因爲它們會再次生成MsSql。 然後使用Add-Migration命令重新生成遷移文件,它應該可以工作。

你也可以在這裏檢查ABP的github倉庫的相關問題https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2267