EntityFramework 5在VS 2012中安装失败

Tec*_*Joe 7 entity-framework nuget visual-studio-2012

我正在尝试从Visual Studio 2012中的程序管理器控制台安装最新版本的EntityFramework.运行install-package命令会产生以下错误:

PM> install-package EntityFramework
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=253898&clcid=0x409. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
    Successfully installed 'EntityFramework 5.0.0'.
    Successfully uninstalled 'EntityFramework 5.0.0'.
    Install failed. Rolling back...
    install-package : Failed to add reference to 'System.Data.Entity'. Please make sure that it is in the Global Assembly Cache.
    At line:1 char:1
    + install-package EntityFramework
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
        + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Run Code Online (Sandbox Code Playgroud)

所以我在Google上做了一些讨论,并提出以下内容进入Web.Config文件.我第二次尝试使用以下条目安装EntityFramwork:

<section name="entityFramework" type="EntityFramework.dll, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
Run Code Online (Sandbox Code Playgroud)

这导致了同样的错误.我的问题是这些:

  • 如何安装此软件包?开箱即用这应该可以工作,并与其他软件包一起工作,这似乎很愚蠢,这个软件包无法快速,轻松地安装.

  • 该软件包的文档与某种形式的FAQ存在于何处?对于安装问题的文档不存在,这似乎很愚蠢.

提前致谢!

::编辑::

我忘了添加我尝试了以下条目到web.config文件:

<assemblies>
    <add assembly="System.Data.Entity, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
Run Code Online (Sandbox Code Playgroud)

...产生了同样的错误.

小智 13

对我们而言,这个错误是由于针对错误的.NET版本造成的 - 我们不小心创建了针对.NET的项目2.将目标框架版本更改为.NET 4解决了问题并允许我们添加NuGet包实体框架.


Bhu*_*ake 3

删除您在文件中所做的所有条目web.config。只需Right Click on your project name in the solution,单击Manage Nuget Packages左手上的 单击Online,然后将右手上的 Entity Framework 放入搜索框中。点击Install

这会自动为你完成所有的事情。