在我的VS2015 WebApi项目中,我尝试使用Package Manager中的以下命令安装NuGet包EntityFramework 6.1.3。该命令成功运行,如下面的消息所示。但是程序包仍未安装,编译项目时出现错误:
PM> Install-Package EntityFramework
Installing NuGet package EntityFramework.6.1.3.
Successfully installed 'EntityFramework 6.1.3' to myWebProjectName
编译错误: 错误NU1001无法解析依赖关系EntityFramework> = 6.1.3。 myWebProjectName C:... \ WebAPI \ ProductService \ src \ ProductService \ project.json
这是我的project.json文件:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.WebApi.OData": "5.7.0",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
更新
项目中的Reference文件夹为空,并且没有安装NuGet软件包,如下面的项目屏幕截图所示:
Solution Explorer窗口:
更新2
关闭项目并重新打开后,Reference文件夹显示两个文件夹DNX 4.5.1和DNX Core5.0,其中包含一些错误图标,如下所示:
答案 0 :(得分:1)
我假设您使用ASP.NET 5模板来创建Web API项目。
右键单击项目中的references文件夹,然后单击“Restore Packages”。然后重建。
我认为DNX Core不支持Entity Framework 6。所以你可能也必须删除该引用。右键单击DNX Core 5.0下的“EntityFramwork”,然后单击“卸载包”。
您是否在此图片中看到了DNX的内容?
答案 1 :(得分:0)