如何升级EF核心1.1的MySql [英] How to Updgrade MySql for EF core 1.1
问题描述
我的原始projects.json文件如下:
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"
]
}
},
这些设置适用于MySql数据库。
我想将EF core升级到1.1,以便可以在存储库中使用Update()方法,如下所示(这是一个不错的一行代码,我不需要将每个属性传入对象分配给原始对象):
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();
}
但是,当我将EF core升级到1.1 时 Microsoft.EntityFrameworkCore: 1.0.0
我的代码在以下几行开始在startup.cs中引发错误:
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<WebAPIDataContext>(options =>
{
options.UseMySQL(Configuration.GetConnectionString("SampleConnection"));
});
我的猜测是升级EF Core打破了对MySql的依赖。这是对的吗?我该如何解决?
My guess is upgrading EF Core broke some dependency with MySql. Is it correct? How can I fix it?
更新:
我删除了 Microsoft.EntityFrameworkCore: 1.0.0
和 MySql.Data.Core: 7.0.4-IR-191
并替换为 MySql.Data.EntityFrameworkCore: 6.10.1-beta
。在我的aspsettings.josn中,我有:
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;"
},
还原软件包后,我重新启动了Visual Studio并构建了解决方案,之后错误:
After restoring packages I restarted visual studio and build the solution which threw me following error:
推荐答案
"MySql.Data.Core": "7.0.4-IR-191",
"MySql.Data.EntityFrameworkCore": "7.0.6-IR31",
两者都已过时,Oracle搞砸了版本控制。参见 NuGet页面。
Both are outdated and Oracle fucked up versioning. See NuGet page.
IR31是最后一个支持EF Core 1.0的版本。 IR-191甚至更老,<< c $ c> 6。* 之一是第一个支持EF Core 1.1的计算机。
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.
现在又出现了 7.0.7-m6
,它似乎也支持EF Core 1.1。 Oracle似乎在跳过这些版本。
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.
后两个版本中的任何一个都应在 6.10.1-beta
或 7.0上运行。 7-m6
。
Either of the later two versions should work 6.10.1-beta
or 7.0.7-m6
.
这篇关于如何升级EF核心1.1的MySql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!