简体   繁体   English

已经安装了'EntityFramework 6.1.3'。无法添加对'System.ComponentModel.DataAnnotations'的引用

[英]'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. 我还是想知道出了什么问题。

  1. Close your Visual studio. 关闭Visual Studio。

  2. From the Start screen, right-click the Windows PowerShell app tile (or search for it in the search bar). 在“开始”屏幕中,右键单击Windows PowerShell应用程序磁贴(或在搜索栏中搜索它)。

  3. Click Run as administrator (Very Important). 单击Run as administrator (非常重要)。

  4. Run this command: Set-ExecutionPolicy Unrestricted 运行以下命令: Set-ExecutionPolicy Unrestricted

  5. Now go back to your visual studio and download your Nuget package(s). 现在回到您的视觉工作室并下载您的Nuget包。

  6. 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.

相关问题 找不到System.ComponentModel.DataAnnotations - System.ComponentModel.DataAnnotations was not found 为什么我不能引用 System.ComponentModel.DataAnnotations? - Why can't I reference System.ComponentModel.DataAnnotations? 我应该添加 System.ComponentModel.DataAnnotations 作为尊敬.net 48 - Should I add System.ComponentModel.DataAnnotations as reverence .net 48 使用System.ComponentModel.DataAnnotations的验证摘要; - Validation Summary using System.ComponentModel.DataAnnotations; System.ComponentModel.DataAnnotations命名空间不存在 - the System.ComponentModel.DataAnnotations namespace does not exist 使用 System.ComponentModel.DataAnnotations 进行模型绑定 - Model binding using System.ComponentModel.DataAnnotations System.ComponentModel.DataAnnotations MaxLength未显示 - System.ComponentModel.DataAnnotations MaxLength not showing Mono将何时支持System.ComponentModel.DataAnnotations? - When will Mono support System.ComponentModel.DataAnnotations? C#EntityFramework和System.ComponentModel.DataAnnotations中都存在类型“ ForeignKeyAttribute” - C# The type 'ForeignKeyAttribute' exists in both EntityFramework and System.ComponentModel.DataAnnotations 为什么实现IValidatabletable的类在另一个类库中使用时需要引用System.ComponentModel.DataAnnotations? - Why classes that implements IValidatableObject requires reference to System.ComponentModel.DataAnnotations when used in another class library?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM