Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFramework 5 Install fails in VS 2012

I'm attempting to install the latest version of the EntityFramework from the Program Manager console in Visual Studio 2012. Running the install-package command yields the following error:

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

So I did some poking around on Google and came up with the following to enter in the Web.Config file. I made a second attempt at installing the EntityFramwork with the following entry:

<section name="entityFramework" type="EntityFramework.dll, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

Which resulted in the same error. My questions are these:

  • How can I get this package installed? Out of the box this should work and does with other packages this seems silly that this package can't be installed quickly and easily.

  • Where does the documentation for this package along with some form of a FAQ exist? This too seems silly that documentation for installation issues does not exist.

Thanks in advance!

::Edit::

I forgot to add I tried the following entry to the web.config file as well:

<assemblies>
    <add assembly="System.Data.Entity, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>

...which yielded the same error.

like image 794
Techie Joe Avatar asked Dec 11 '12 17:12

Techie Joe


People also ask

Is ef6 still supported?

Although Entity Framework 6. x is still supported, it is no longer being developed and will only receive fixes for security issues.

How can I change Entity Framework 6 to 5?

In this situation you can upgrade to EF5 using the following steps: Select Tools -> Library Package Manager -> Package Manager Console. Run Install-Package EntityFramework -version 5.0. 0.


1 Answers

This error was, for us, caused by targeting the wrong version of .NET - we'd accidentally created our project targeting .NET 2. Changing the target framework version to .NET 4 fixed the problem and allowed us to add the NuGet package for Entity Framework.

like image 144
Martin Wilkerson Avatar answered Oct 14 '22 00:10

Martin Wilkerson