Unable to install EntityFramework 6.1.3 in VS2015 web project

爷,独闯天下 提交于 2020-01-05 17:57:57

问题


In my VS2015 WebApi project, I try to install NuGet package EntityFramework 6.1.3 using the following command from Package Manager. The command runs with success as the message below shows. But the package is still not installed and I get an error when I compile the project:

PM> Install-Package EntityFramework
Installing NuGet package EntityFramework.6.1.3.
Successfully installed 'EntityFramework 6.1.3' to myWebProjectName

The compile error: Error NU1001 The dependency EntityFramework >= 6.1.3 could not be resolved. myWebProjectName C:...\WebAPI\ProductService\src\ProductService\project.json

Here is my project.json file:

{
  "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"
  ]
}

UPDATE

The Reference folder in the project is empty and there are no NuGet packages installed as shown in the project screenshots below:

Solution Explorer Window:

UPDATE 2

After I closed the project and re-opened it, the Reference folder is showing two folders DNX 4.5.1 and DNX Core5.0 with some error icons as shown below:


回答1:


I'm assuming you used the ASP.NET 5 template to create your Web API project.

Right click on your references folder, in your project, and click "Restore Packages". Then rebuild.

I don't think Entity Framework 6 is supported for DNX Core. So you might have to remove that reference as well. Right-click on "EntityFramwork" under DNX Core 5.0 and click Uninstall Package.

Do you see the DNX stuff like in this image?




回答2:


Replace Entity FrameWork "EntityFramework": "6.1.3", by "EntityFramework.Commands": "7.0.0-rc1-final", It Work Properly then bulid it. Also see the screeshot i added.



来源:https://stackoverflow.com/questions/35950206/unable-to-install-entityframework-6-1-3-in-vs2015-web-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!