[英]'EntityFramework 6.1.3' already installed. Failed to add reference to 'System.ComponentModel.DataAnnotations'
My winforms solution was working, but when I re-opened it, some of the references were no longer working. 我的winforms解决方案正在运行,但是当我重新打开它时,一些引用不再有效。 Hence I removed all the references in the project including the references to microsoft dlls. 因此,我删除了项目中的所有引用,包括对microsoft dll的引用。
Now I am trying to add back the references. 现在我正在尝试添加引用。
What should I do first? 我该怎么办?
I tried using package manager to add Entity Framework, but got an error. 我尝试使用包管理器添加实体框架,但收到错误。 'EntityFramework 6.1.3' already installed. 已经安装了'EntityFramework 6.1.3'。 Failed to add reference to 'System.ComponentModel.DataAnnotations'. 无法添加对“System.ComponentModel.DataAnnotations”的引用。
Now When I open package manager, and select On Line, Entity Framework is ticked. 现在,当我打开包管理器,并选择On Line时,实体框架被勾选。 However when I select Installed Packages it states "No packages are installed in the current solution" 但是,当我选择Installed Packages时,它会指出“当前解决方案中没有安装任何软件包”
When I try to build I get an error message 当我尝试构建时,我收到一条错误消息
Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is E:\EShared\devnet10\SBD.Scheduling\\.nuget\NuGet.targets. E:\EShared\devnet10\SBD.Scheduling\SBD.Scheduling.Core\SBD.Scheduling.Core.csproj 117 5 SBD.Scheduling.Core
I tried adding a reference to System.ComponentModel.DataAnnotations but it shows in the references with a little yellow exclamation mark. 我尝试添加对System.ComponentModel.DataAnnotations的引用,但它在引用中显示带有一点黄色感叹号。
When I double click the reference icon in solution exporer I get the message 当我双击解决方案exporer中的参考图标时,我收到消息
The project cannot be viewed in the object browser because it is unavailable or not yet built
After using version control to revert back to my version with EF6.0.2 , I was then able to install 6.0.3 successfully. 使用版本控制恢复到使用EF6.0.2的版本后,我成功安装了6.0.3。
I would still like to know what went wrong. 我还是想知道出了什么问题。
Close your Visual studio. 关闭Visual Studio。
From the Start screen, right-click the Windows PowerShell app tile (or search for it in the search bar). 在“开始”屏幕中,右键单击Windows PowerShell应用程序磁贴(或在搜索栏中搜索它)。
Click Run as administrator
(Very Important). 单击Run as administrator
(非常重要)。
Run this command: Set-ExecutionPolicy Unrestricted
运行以下命令: Set-ExecutionPolicy Unrestricted
Now go back to your visual studio and download your Nuget package(s). 现在回到您的视觉工作室并下载您的Nuget包。
Run this command to set it back to secure setting: Set-ExecutionPolicy Restricted
运行此命令将其设置回安全设置: Set-ExecutionPolicy Restricted
You can use this command from the Package Manager Console: 您可以从程序包管理器控制台使用此命令:
Update-Package –reinstall EntityFramework Update-Package -reinstall EntityFramework
If you just want to reinstall everything that is defined in packages.config, use this command: 如果您只想重新安装packages.config中定义的所有内容,请使用以下命令:
nuget install packages.config
It will also restore the missing packages. 它还将恢复丢失的包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.