Cannot uninstall entityframework package from mvc project - c#

While trying to uninstall Entityframework in Package Manager Console by typing uninstall-package Entityframework, following error is showing up:
uninstall-package : Unable to uninstall 'EntityFramework.6.4.4' because 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' depends on it.
While trying to uninstall Microsoft.AspNet.Identity.EntityFramework.2.2.3, following error shows up:
uninstall-package : Package 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' to be uninstalled could not be found in project 'HMS'
After failing multiple attempts to uninstall entityframework package in Package Manager Console, I decided to manually delete the respective packages folders from Packages folder inside project directory, but Nuget is restoring the package folders again i.e.,
PM> uninstall-package entityframework
Restoring NuGet package EntityFramework.6.4.4.
Restoring NuGet package Microsoft.AspNet.Identity.EntityFramework.2.2.3.
Restoring NuGet package Microsoft.AspNet.Identity.Owin.2.2.3.
Restoring NuGet package Microsoft.AspNet.Identity.Core.2.2.3.
Adding package 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
Adding package 'EntityFramework.6.4.4' to folder 'E:\Visual Studio Projects\HMS\packages'
Added package 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.identity.owin/2.2.3/microsoft.aspnet.identity.owin.2.2.3.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.identity.core/2.2.3/microsoft.aspnet.identity.core.2.2.3.nupkg
Added package 'EntityFramework.6.4.4' to folder 'E:\Visual Studio Projects\HMS\packages'
OK https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.identity.owin/2.2.3/microsoft.aspnet.identity.owin.2.2.3.nupkg 170ms
OK https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.identity.core/2.2.3/microsoft.aspnet.identity.core.2.2.3.nupkg 178ms
Installed Microsoft.AspNet.Identity.Core 2.2.3 from https://api.nuget.org/v3/index.json with content hash Mv5FpoaxspE8hlWLE4r1IdZtovg/OyFgVRhxQbx47J4sqdLImN1hnM1lnwCj+/wLmqtqFk/RYMoZ5GAcwm/00g==.
Installed Microsoft.AspNet.Identity.Owin 2.2.3 from https://api.nuget.org/v3/index.json with content hash gNr7dQGE23hAtWmSZVmKPJ+DKBw/obh68Ub7M5cCUiRNAqg6+6Jb3T7en4Fuw8R/8H5/sIsecrfT3MbK2/FzEg==.
Adding package 'Microsoft.AspNet.Identity.Core.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
Adding package 'Microsoft.AspNet.Identity.Owin.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
Added package 'Microsoft.AspNet.Identity.Core.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
Added package 'Microsoft.AspNet.Identity.Owin.2.2.3' to folder 'E:\Visual Studio Projects\HMS\packages'
Attempting to gather dependency information for package 'EntityFramework.6.4.4' with respect to project 'HMS', targeting '.NETFramework,Version=v4.7.2'
Resolving actions to uninstall package 'EntityFramework.6.4.4'
uninstall-package : Unable to uninstall 'EntityFramework.6.4.4' because 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' depends on it.
At line:1 char:1
+ uninstall-package entityframework
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Uninstall-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UninstallPackageCommand
Time Elapsed: 00:00:00.6990767
Where do I go now?

Related

The package requires NuGet client version '3.6.0' or above

I want to install Microsoft.EntityFrameworkCore and its component. I am using Visual Studio 2015 with NuGet Client version previously 3.5.0 and now I have 3.6.0-rtm-2511 (which is the latest) downloaded from https://www.nuget.org/downloads as instructed by error report. I don't know why issue still persist that I need to have 3.6.0 or higher.
How to update my NuGet Package Manager in other way?
I can't find my Nuget Package Manager for Visual Studio in Update from Tools > Extension and Updates > Updates > Visual Studio Gallery.
I can only see it in Tools > Extension and Updates > Installed but there is no update for it but I noticed that 'Automatically update this extension' is checked.
Result from PM Console
PM> install-package microsoft.entityframeworkcore.sqlserver
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.entityframeworkcore.sqlserver/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.entityframeworkcore.sqlserver/index.json 329ms
Retrieving package 'Microsoft.EntityFrameworkCore.SqlServer 2.1.1' from 'nuget.org'.
Install failed. Rolling back...
Uninstalling NuGet package Microsoft.EntityFrameworkCore.SqlServer.2.1.1.
Executing nuget actions took 162.34 ms
install-package : The 'Microsoft.EntityFrameworkCore.SqlServer 2.1.1' package requires NuGet client version '3.6.0' or above, but the current NuGet
version is '3.6.0-rtm-2511'. To upgrade NuGet, please go to http://docs.nuget.org/consume/installing-nuget
At line:1 char:1
+ install-package microsoft.entityframeworkcore.sqlserver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:33.0573364
The package requires NuGet client version '3.6.0' or above
This is a known issue about nuget. NuGet team fixed it for Nuget 4 which comes with VS2017, but 2015 users are left behind.
Ticket: https://github.com/NuGet/Home/issues/6403
Besides, NuGet team will consider a fix. At this time there are no plans to release a new version of NuGet for VS 2015.
So if you want to use the package Microsoft.EntityFrameworkCore.SqlServer 2.1.1, you have to update your Visual Studio 2015 to Visual Studio 2017. Or if the lower version of this package is acceptable to you, you can use the version Microsoft.EntityFrameworkCore.SqlServer 2.0.3
Hope this helps.
Edit the files:
%userprofile%\.nuget\packages\microsoft.entityframeworkcore\3.1.8\microsoft.entityframeworkcore.nuspec
%userprofile%\.nuget\packages\microsoft.entityframeworkcore.abstractions\3.1.8\microsoft.entityframeworkcore.abstractions.nuspec
%userprofile%\.nuget\packages\microsoft.entityframeworkcore.analyzers\3.1.8\microsoft.entityframeworkcore.analyzers.nuspec
%userprofile%\.nuget\packages\microsoft.entityframeworkcore.relational\3.1.8\microsoft.entityframeworkcore.relational.nuspec
%userprofile%\.nuget\packages\microsoft.entityframeworkcore.tools\3.1.8\microsoft.entityframeworkcore.tools.nuspec
Change line 3 from:
<metadata minClientVersion="3.6">
to:
<metadata minClientVersion="3.6.0-rtm-2511">
Now go back to the Package Manager Console and try the install again:
Worked for me.
Try installing the package from Nuget Package Manager (Manage NuGet Packages)and not from console. The package manager will provide you option to update your NUGET application. Look in the 'Visual Studio Gallery' section of the 'Extension and Updates' window that pops up.

How to add a package from a local source?

I'm trying to build a C# console application using Visual Studio Code but when I try to install packages the application uses wrong local folder with as a local source.
I have dotnet installed in my C program files, I think the program will be solved if I can use my dotnet folder as a local source but I don't know how to do it.
I tried these commands in terminal :
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.Tools
and I get this error:
MovieAPP>dotnet add package Microsoft.EntityFrameworkCore Writing C:\Users\Ahmed\AppData\Local\Temp\tmpB0AD.tmp info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore' into project 'E:\courses\C-Sharp\MovieAPP\MovieAPP.csproj'. log : Restoring packages for E:\courses\C-Sharp\MovieAPP\MovieAPP.csproj...
Writing C:\Users\user\AppData\Local\Temp\tmpACF8.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore' into project 'E:\courses\C-Sharp\MovieAPP\MovieAPP.csproj'.
log : Restoring packages for E:\courses\C-Sharp\MovieAPP\MovieAPP.csproj...
error: The local source 'C:\Users\user\Downloads\Compressed\WebMatrixExtensionsGallery' doesn't exist.

Unable to install package UnmanagedExports

In the NuGet Package Manager Console in Visual Studio Express 2012 for Windows 8, I hit
PM > Install-Package UnmanagedExports
I get the following error :
Installing 'UnmanagedExports 1.2.7'.
Successfully installed 'UnmanagedExports 1.2.7'.
Adding 'UnmanagedExports 1.2.7' to JNAExample.
Uninstalling 'UnmanagedExports 1.2.7'.
Successfully uninstalled 'UnmanagedExports 1.2.7'.
Install failed. Rolling back...
Install-Package : Could not install package 'UnmanagedExports 1.2.7'.
You are trying to install this package into a project that
targets'.NETCore,Version=v4.5', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package UnmanagedExports
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo :
NotSpecified: (:[InstallPackage],InvalidOperationException
+ FullyQualifiedErrorId :
NuGetCmdletUnhandledExceptionNuGet.PowerShell.Commands.InstallPackageCommand
I created a New Project under Visual C# as Class Library.
How to solve this issue ?
The UnmanagedExports NuGet package has an assembly in the lib/net folder inside the NuGet package. Which means it supports projects that target the full .NET Framework, any version. So it does not support UWP projects.
You would need to find another NuGet package, or find the source, if it is available, and compile that in a UWP project or a project that is compatible.

Sending solution to new developer with tfs - package issues

I have shared a solution with another developer via TFS and we are having some trouble with the packages.
In the source control explorer I see what is shared is a packages folder with each package folder and a .nupkg file in each.
I read that we needed to run Update-Package to install all of these based on the packages.config folder. When we did that there was an error on EntityFramework. Here are the logs.
No package updates are available from the current package source for project 'ConfigManager'.
Attempting to gather dependency information for multiple packages with respect to project 'BusinessServices.Tests', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NUnit 3.2.1' from 'packages.config'
Successfully uninstalled 'NUnit 3.2.1' from BusinessServices.Tests
GET https://api.nuget.org/v3-flatcontainer/nunit/3.5.0/nunit.3.5.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/nunit/3.5.0/nunit.3.5.0.nupkg 56ms
Installing NUnit 3.5.0.
Adding package 'NUnit.3.5.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to 'packages.config'
Successfully installed 'NUnit 3.5.0' to BusinessServices.Tests
Removing package 'NUnit 3.2.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'NUnit 3.2.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Attempting to gather dependency information for multiple packages with respect to project 'PrintServices.Tests', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NUnit 2.6.4' from 'packages.config'
Successfully uninstalled 'NUnit 2.6.4' from PrintServices.Tests
Removed package 'Moq 4.5.9' from 'packages.config'
Successfully uninstalled 'Moq 4.5.9' from PrintServices.Tests
Executing script file 'C:\WORK\TFS\TransitProjects\HmkApi\packages\AutoMapper.3.3.1\tools\net40\uninstall.ps1'
Removed package 'AutoMapper 3.3.1' from 'packages.config'
Successfully uninstalled 'AutoMapper 3.3.1' from PrintServices.Tests
GET https://api.nuget.org/v3-flatcontainer/automapper/5.1.1/automapper.5.1.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/automapper/5.1.1/automapper.5.1.1.nupkg 120ms
Installing AutoMapper 5.1.1.
Adding package 'AutoMapper.5.1.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to 'packages.config'
Successfully installed 'AutoMapper 5.1.1' to PrintServices.Tests
GET https://api.nuget.org/v3-flatcontainer/moq/4.5.28/moq.4.5.28.nupkg
OK https://api.nuget.org/v3-flatcontainer/moq/4.5.28/moq.4.5.28.nupkg 113ms
Installing Moq 4.5.28.
Adding package 'Moq.4.5.28' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Moq.4.5.28' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Moq.4.5.28' to 'packages.config'
Successfully installed 'Moq 4.5.28' to PrintServices.Tests
Package 'NUnit.3.5.0' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to 'packages.config'
Successfully installed 'NUnit 3.5.0' to PrintServices.Tests
Removing package 'AutoMapper 3.3.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'AutoMapper 3.3.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Attempting to gather dependency information for multiple packages with respect to project 'PrintServices', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NLog 4.3.3' from 'packages.config'
Successfully uninstalled 'NLog 4.3.3' from PrintServices
GET https://api.nuget.org/v3-flatcontainer/nlog/4.3.11/nlog.4.3.11.nupkg
OK https://api.nuget.org/v3-flatcontainer/nlog/4.3.11/nlog.4.3.11.nupkg 283ms
Installing NLog 4.3.11.
Adding package 'NLog.4.3.11' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NLog.4.3.11' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NLog.4.3.11' to 'packages.config'
Successfully installed 'NLog 4.3.11' to PrintServices
Attempting to gather dependency information for multiple packages with respect to project 'Resolver', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'Unity 2.1.505.0' from 'packages.config'
Successfully uninstalled 'Unity 2.1.505.0' from Resolver
Removed package 'CommonServiceLocator 1.0' from 'packages.config'
Successfully uninstalled 'CommonServiceLocator 1.0' from Resolver
GET https://api.nuget.org/v3-flatcontainer/commonservicelocator/1.3.0/commonservicelocator.1.3.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/commonservicelocator/1.3.0/commonservicelocator.1.3.0.nupkg 8ms
Installing CommonServiceLocator 1.3.0.
Adding package 'CommonServiceLocator.1.3.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'CommonServiceLocator.1.3.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'CommonServiceLocator.1.3.0' to 'packages.config'
Successfully installed 'CommonServiceLocator 1.3.0' to Resolver
GET https://api.nuget.org/v3-flatcontainer/unity/4.0.1/unity.4.0.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/unity/4.0.1/unity.4.0.1.nupkg 4ms
Installing Unity 4.0.1.
Adding package 'Unity.4.0.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Unity.4.0.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Unity.4.0.1' to 'packages.config'
Successfully installed 'Unity 4.0.1' to Resolver
Attempting to gather dependency information for multiple packages with respect to project 'BusinessServices', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NLog 4.3.3' from 'packages.config'
Successfully uninstalled 'NLog 4.3.3' from BusinessServices
Removed package 'EntityFramework 5.0.0' from 'packages.config'
Successfully uninstalled 'EntityFramework 5.0.0' from BusinessServices
Removed package 'AutoMapper 4.2.1' from 'packages.config'
Successfully uninstalled 'AutoMapper 4.2.1' from BusinessServices
Package 'AutoMapper.5.1.1' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to 'packages.config'
Successfully installed 'AutoMapper 5.1.1' to BusinessServices
Package 'EntityFramework.6.1.3' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Install failed. Rolling back...
Package 'EntityFramework 6.1.3' does not exist in project 'BusinessServices'
Removed package 'AutoMapper 5.1.1' from 'packages.config'
Package 'AutoMapper 4.2.1' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Package 'EntityFramework 5.0.0' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Package 'NLog 4.3.3' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removing package 'EntityFramework 6.1.3' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'EntityFramework 6.1.3' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Update-Package : Failed to add reference to 'EntityFramework'.
At line:1 char:1
+ Update-Package
+ ~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
At this point I am pretty stuck, not sure what my options are?

Installing Entity Framework fails in Visual Studio 2015

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.
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)
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.
Try to remove all the EF nuget packages installed on your solution and then reinstall the only one that you need.
Try to disconnect references between projects and than try to install EF. Hope it'll help
Relaunching Visual Studio as Admin and retry to install the package did the trick for me.

Categories