5

I'm reading/coding along with the Apress book Pro ASP.NET MVC 5 by Adam Freeman. In chapter 7 (p. 174), we're supposed to install Entity Framework using the following commands:

Install-Package EntityFramework -projectname SportsStore.Domain
Install-Package EntityFramework -projectname SportsStore.WebUI

But this fails. Here is the output:

Attempting to gather dependencies information for package 'EntityFramework.6.1.3' with respect to project 'SportsStore.Domain', targeting '.NETFramework,Version=v4.5.1'
Attempting to resolve dependencies for package 'EntityFramework.6.1.3' with DependencyBehavior 'Lowest'
Resolving actions to install package 'EntityFramework.6.1.3'
Resolved actions to install package 'EntityFramework.6.1.3'
Adding package 'EntityFramework.6.1.3' to folder 'C:\git\SportsStore\packages'
Added package 'EntityFramework.6.1.3' to folder 'C:\git\SportsStore\packages'
Added package 'EntityFramework.6.1.3' to 'packages.config'
Executing script file 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\init.ps1'
Executing script file 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\install.ps1'

Type 'get-help EntityFramework' to see all available Entity Framework commands.
Successfully installed 'EntityFramework 6.1.3' to SportsStore.Domain
Install failed. Rolling back...
Removed package 'EntityFramework 6.1.3' from 'packages.config'
Removing package 'EntityFramework 6.1.3' from folder 'C:\git\SportsStore\packages'
Access to the path 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\EntityFramework.PowerShell.Utility.dll' is denied.
Access to the path 'EntityFramework.PowerShell.Utility.dll' is denied.
Removed package 'EntityFramework 6.1.3' from folder 'C:\git\SportsStore\packages'
Install-Package : An item with the same key has already been added.
At line:1 char:1
+ Install-Package EntityFramework -projectname SportsStore.Domain
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

One or more packages could not be completely uninstalled: 'C:\git\SportsStore\packages\EntityFramework.6.1.3'. Restart Visual Studio to finish uninstall.

The book is instructing us to install specific versions of all other libraries (e.g. Microsoft.Aspnet.Mvc 5.0.0), but does not mention which version of EF to install, so I've tried installing different versions of EF, but keep getting the same error. (Install failed. Rolling back...)

I'm running VS2015 as administrator.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Just tried installing EF to a clean new MVC-project, and that works just fine, so this might be related to versioning? –  Aug 30 '15 at 15:00
  • Thanks a lot for the question. I also has the same issue while reading the same book. – Vikram Jul 01 '16 at 07:21

5 Answers5

10

Seems NuGet itself was causing these issues (probably related to https://github.com/NuGet/Home/issues/1239, as I was seeing the same 'always rolling back' issue as discussed in that thread)

Updating NuGet solved it for me. (Updated from version 3.0.60624.657 to 3.1.60724.766)

Updating NuGet

  • I was on Visual Studio 2015 update 2. I upgraded it to update 3 and it worked. For sure nuget package manager would have also got updated during this update. – RBT Jul 28 '16 at 08:47
1

These references were set up earlier in the project:

SportsStore.WebUI -> SportsStore.Domain 
SportsStore.UnitTests -> SportsStore.Domain and SportsStore.WebUI

I removed the references for each project and then ran the install-package command for the Entity Framework as directed. That worked fine.

I then re-added the references.

0

Try to remove all the EF nuget packages installed on your solution and then reinstall the only one that you need.

Hernan Guzman
  • 1,235
  • 8
  • 14
0

Try to disconnect references between projects and than try to install EF. Hope it'll help

0

Relaunching Visual Studio as Admin and retry to install the package did the trick for me.

Antonin GAVREL
  • 9,682
  • 8
  • 54
  • 81