如何更新MySql for EF core 1.1

时间:2017-03-17 13:40:38

标签: asp.net-core entity-framework-core

My Original projects.json文件如下:

"dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.0",
    "MySql.Data.Core": "7.0.4-IR-191",
    "MySql.Data.EntityFrameworkCore": "7.0.6-IR31",
    "Swashbuckle": "6.0.0-beta902",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"

  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

这些设置适用于我的MySql数据库。 我想将EF核心升级到1.1,以便我可以在我的存储库中使用Update()方法,如下所示(这是一个很好的行代码,我不需要将每个属性传入对象分配给原始对象):

  public void UpdateBook(long id, Book book)
  {  
     var originalBook=  _db.Books.FirstOrDefault(o => o.Id == id);
     _db.Entry(originalBook).CurrentValues.SetValues(book);
     _db.SaveChanges();
  }

然而,当我将EF核心升级到1.1 "Microsoft.EntityFrameworkCore": "1.0.0"时,我的代码开始在这些行中的startup.cs中抛出错误:

services.AddApplicationInsightsTelemetry(Configuration);
services.AddDbContext<WebAPIDataContext>(options =>
     {
            options.UseMySQL(Configuration.GetConnectionString("SampleConnection"));
            });

我的猜测是升级EF Core打破了MySql的一些依赖。这是对的吗?我该如何解决?

更新

我删除了"Microsoft.EntityFrameworkCore": "1.0.0""MySql.Data.Core": "7.0.4-IR-191",并替换为"MySql.Data.EntityFrameworkCore": "6.10.1-beta"。在我的aspsettings.josn中我有:

"ConnectionStrings": {
    "SampleConnection": "server=localhost;userid=root;pwd=root;port=3306;database=aspnet;sslmode=none;"
  },

恢复软件包后,我重新启动了visual studio并构建了解决方案,让我误以为:

enter image description here

1 个答案:

答案 0 :(得分:1)

"MySql.Data.Core": "7.0.4-IR-191",
"MySql.Data.EntityFrameworkCore": "7.0.6-IR31",

两者都已过时,Oracle搞砸版本化。请参阅NuGet page

IR31是支持EF Core 1.0的最后一个版本。 IR-191甚至更老,其中一个6.*是第一个支持EF Core 1.1的。

现在又有7.0.7-m6,它似乎也支持EF Core 1.1。 Oracle似乎正在玩这些版本的跳绳。

后两个版本中的任何一个都应该有效6.10.1-beta7.0.7-m6