ef.extensions mysql,如何升级EF核心1.1的MySql

My Original projects.json file is like following:

"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"

]

}

},

These settings work with my MySql database.

I wanted to upgrade EF core to 1.1 so that I could use Update() method in my repository like following (this is nice-one line code and I do not need to assign each attribute incoming object to original object):

public void UpdateBook(long id, Book book)

{

var originalBook= _db.Books.FirstOrDefault(o => o.Id == id);

_db.Entry(originalBook).CurrentValues.SetValues(book);

_db.SaveChanges();

}

However, when I upgraded EF core to 1.1 "Microsoft.EntityFrameworkCore": "1.0.0" my code started throwing error in startup.cs at these lines:

services.AddApplicationInsightsTelemetry(Configuration);

services.AddDbContext(options =>

{

options.UseMySQL(Configuration.GetConnectionString("SampleConnection"));

});

My guess is upgrading EF Core broke some dependency with MySql. Is it correct? How can I fix it?

UPDATE:

I removed "Microsoft.EntityFrameworkCore": "1.0.0" and "MySql.Data.Core": "7.0.4-IR-191" and replaced with "MySql.Data.EntityFrameworkCore": "6.10.1-beta". In my aspsettings.josn I have:

"ConnectionStrings": {

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

},

After restoring packages I restarted visual studio and build the solution which threw me following error:

rpMkE.png

解决方案

"MySql.Data.Core": "7.0.4-IR-191",

"MySql.Data.EntityFrameworkCore": "7.0.6-IR31",

Both are outdated and Oracle fucked up versioning. See NuGet page.

The IR31 was the last version to support EF Core 1.0. IR-191 is even older and one of the 6.* was the first one to support EF Core 1.1.

Now there is again 7.0.7-m6 which also seems to support EF Core 1.1. Oracle seems to be playing rope skipping with the versions.

Either of the later two versions should work 6.10.1-beta or 7.0.7-m6.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值