我正在尝试在VS 2015,Update 3中安装Entity Framework Core,因此我可以从现有数据库中反向设计EF模型。我按照微软的指示,在这里:https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db。
但是,只要将此行添加到我的project.json文件中:
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0"
我得到了一个"包恢复失败"我的引用中的错误,说依赖无法解决。无论我指定什么版本,我都会得到同样的错误。
以下是我的package.json文件的完整内容 - 我添加的唯一一行是上面提到的那一行。当我从"新的ASP.NET核心Web应用程序"创建项目时,所有其余的都默认存在。模板。
我尝试添加对Microsoft.EntityFrameworkCore的引用,如此处所示:How to resolve the dependency on Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools?,但是我得到了与该引用相同的错误消息(同样,无论我指定的版本是什么)。
任何人都可以解释问题是什么,以及一个人应该如何从提供的最少信息中解决这个问题?
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
答案 0 :(得分:0)
原来问题是我的包源无效。我删除了NuGet包管理器中的无效源,然后我就可以添加引用了。