24

So im downloading a project at home from work over team foundation server. I download the project and it won't compile because of the error. Warning 2 The referenced component 'EntityFramework' could not be found. Could anyone offer guidance in how I can get entity framework to work. I installed nuget package.

Thankyou

qwertyuywertwer
  • 271
  • 1
  • 2
  • 9

6 Answers6

33

I suggest you to check:

1) "Allow NuGet to download missing packages during build" ticked

Tool --> Options... --> Package Manager --> General enter image description here

2) "Project selected" ticked

Solution Explorer --> right-click on the solution/project --> Manage NuPackages enter image description here

3) Rebuild Solution

enter image description here

EDIT

For completeness I would like to add that if you are working with a CI system (e.g. Jenkins) or you are using MSBuild on the command line, you need to select Enable NuGet Package Restore to make it work:

Enable NuGet Package Restore http://docs.nuget.org/docs/Workflows/images/enable-package-restore.png

Filippo Vitale
  • 7,597
  • 3
  • 58
  • 64
  • Unfortunately there are many cases where "Allow NuGet to download missing packages" is enabled, but NuGet still doesn't actually download and restore the references. I am using Visual Studio 2015 Update 3. The user-experience with NuGet is still far from perfect. – Dai Feb 24 '17 at 18:59
  • 1
    @Dai: Sometimes, it is necessary to delete the content of the _packages_ folder. If you do that, the package restore always works without fail. – Marc Sigrist Jun 16 '17 at 15:48
19

I had the same problem. I solved it like this:

  1. Choose References > Right-click > Add Reference ...
  2. Choose Browse tab
  3. Find your Project Folder > packages > EntityFramework.4.1.10331.0 > lib
  4. Choose EntityFramework.dll
  5. Click OK
Scott
  • 21,211
  • 8
  • 65
  • 72
Bena Waketversa
  • 199
  • 1
  • 2
  • Obviously the details are now different (EntityFramework has had quite a few revisions since this answer), but this was the best solution when NuGet already had the package installed but the project had the wrong path for the dll. – Ellesedil Apr 07 '14 at 20:35
  • This was a useful answer. I recently upgraded the version of one package using NuGet but the reference in the csproj file was not updated to the more recent DLL. – StayOnTarget Aug 31 '16 at 13:16
  • This worked for me. Using TFS 2015 and VS 2015, I branched the main code line and this reference was broken in the branched version. – Gridly Feb 06 '17 at 17:19
  • Yeah, this finally worked for me, and now I recall I used that trick in a completely different scenario. Always a good way to try if you want to avoid pulling in a whole hierarchy of packages once _again_ in another project when all that Visual Studio really wants is a specific library due to (in this case) the class `DbContext` being inherited from. – Jonas May 03 '19 at 16:20
4

This happened to me, after I moved projects to a subfolder. Then, the relative paths to the packages folder were not correct anymore.

Got errors like that:

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets. PROJECTNAME D:\VSTS\TEAMPROJECT\src\PROJECTFOLDER\PROJECTNAME.csproj

enter image description here

Fixed it by editing the *.csproj file and corrected the relative paths, in my case from ..\packages to ..\..\packages

Also make sure to check the paths under

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
martinoss
  • 5,268
  • 2
  • 45
  • 53
1

There are good ways suggested by the developers, you may also try this solution to solve your problem.

In your case your project has a reference to the EntityFramework library, but library it self is not available to you project. You may try either the following:

  • If you have NuGet package manager:

Click on Project-> Manage NuGet Packages. It will open following window.

Find the EntityFramework and click Install.

NuGet Package Window


- Alternatively, Download the EntityFramework library to your computer, then

Right-Click the Prject-> Add References...-> Browse-> Locate your EntityFramework library-> Click OK

Like this image


- Optionally you may use package manager to install library reference,
check this link package-manager-console (Note: This might require NuGet Package manager)
1

I solved this issue by adding Entity Framework reference (Add ref) under C:\ Prog Files\Entity...\Binaries\Entity Framework.dll into my project. Hope this helps!

0

An old thread, but for anyone that this may help..

What worked for me was to go to the 'Packages' folder in the root of my solution and delete the EntityFramework.6.4.4 folder.

Then, go to Manage Nuget Packages menu option, and this banner pops up:

enter image description here

After pressing Restore the missing reference was restored.

Bandito
  • 330
  • 4
  • 15