问题
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<WebAPIDataContext>(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:
回答1:
"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
.
来源:https://stackoverflow.com/questions/42859077/how-to-updgrade-mysql-for-ef-core-1-1