C# 找不到引用的组件“EntityFramework”。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10950638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:54:53  来源:igfitidea点击:

The referenced component 'EntityFramework' could not be found.

c#model-view-controller

提问by qwertyuywertwer

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.

所以我在家里通过团队基础服务器从工作中下载了一个项目。我下载了该项目,但由于错误而无法编译。警告 2 找不到引用的组件“EntityFramework”。任何人都可以提供有关如何使实体框架正常工作的指导。我安装了nuget包。

Thankyou

谢谢

采纳答案by Filippo Vitale

I suggest you to check:

我建议你检查:

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

1)勾选“允许 NuGet 在构建期间下载丢失的包”

Tool --> Options... --> Package Manager --> Generalenter image description here

Tool --> Options... --> Package Manager --> General在此处输入图片说明

2) "Project selected"ticked

2)“项目选择”打勾

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

Solution Explorer --> right-click on the solution/project --> Manage NuPackages在此处输入图片说明

3) Rebuild Solution

3)重建方案

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 Restoreto make it work:

为了完整起见,我想补充一点,如果您正在使用 CI 系统(例如 Jenkins)或者您在命令行上使用 MSBuild,则需要选择启用 NuGet 包还原以使其工作:

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

启用 NuGet 包还原 http://docs.nuget.org/docs/Workflows/images/enable-package-restore.png

回答by Bena Waketversa

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

我有同样的问题。我是这样解决的:

  1. Choose References> Right-click > Add Reference ...
  2. Choose Browsetab
  3. Find your Project Folder> packages> EntityFramework.4.1.10331.0> lib
  4. Choose EntityFramework.dll
  5. Click OK
  1. 选择References> 右键单击​​ >Add Reference ...
  2. 选择Browse标签
  3. 找到您的项目文件夹> packages> EntityFramework.4.1.10331.0>lib
  4. 选择 EntityFramework.dll
  5. 点击 OK

回答by Bena Waketversa

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:

在您的情况下,您的项目引用了 EntityFramework 库,但它本身的库对您的项目不可用。您可以尝试以下任一方法:

  • If you have NuGet package manager:
  • 如果您有 NuGet 包管理器:

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

Find the EntityFramework and click Install.

单击项目-> 管理 NuGet 包。它将打开以下窗口。

找到 EntityFramework 并单击安装。

NuGet Package Window

NuGet 包窗口



- 或者,将 EntityFramework 库下载到您的计算机,然后

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

右键单击项目-> 添加引用...-> 浏览-> 找到您的 EntityFramework 库-> 单击确定

Like this image

喜欢这张图



- 您可以选择使用包管理器来安装库参考,


请查看此链接package-manager-console包管理器控制台(注意:这可能需要 NuGet 包管理器)

回答by Ankur Gupta

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!

我通过将 C:\ Prog Files\Entity...\Binaries\Entity Framework.dll 下的实体框架引用(添加引用)添加到我的项目中解决了这个问题。希望这可以帮助!

回答by martinoss

This happened to me, after I moved projectsto 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

此项目引用此计算机上缺少的 NuGet 包。使用 NuGet Package Restore 来下载它们。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105。丢失的文件是 ..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets。项目名称 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 ..\packagesto ..\..\packages

通过编辑 *.csproj 文件并更正相对路径来修复它,在我的情况下从..\packages..\..\packages

Also make sure to check the paths under

还要确保检查下的路径

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">