Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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. Hence I removed all the references in the project including the references to microsoft dlls.

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. Failed to add reference to 'System.ComponentModel.DataAnnotations'.

Now When I open package manager, and select On Line, Entity Framework is ticked. However when I select Installed Packages it states "No packages are installed in the current solution"

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.

When I double click the reference icon in solution exporer I get the message

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.

I would still like to know what went wrong.

like image 579
Kirsten Avatar asked Mar 16 '23 13:03

Kirsten


1 Answers

  1. Close your Visual studio.

  2. From the Start screen, right-click the Windows PowerShell app tile (or search for it in the search bar).

  3. Click Run as administrator (Very Important).

  4. Run this command: Set-ExecutionPolicy Unrestricted

  5. Now go back to your visual studio and download your Nuget package(s).

  6. Run this command to set it back to secure setting: Set-ExecutionPolicy Restricted

like image 66
Swapnil Tamse Avatar answered Apr 28 '23 12:04

Swapnil Tamse