36

I'm trying to install the dotnet-ef tool via the dotnet-cli.

The command that I enter: dotnet tool install --global dotnet-ef

I gives me the following error:

The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

I'm using dotnet 3.0, I believe I didn't have this problem on MacOS, I'm now trying to execute the same command on my Windows 10 machine and it gives me that error.

Some info using dotnet --info command:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download 
1
  • 1
    you can try nuget package manager console Commented Nov 8, 2019 at 10:11

9 Answers 9

59

I got it working by adding the --version flag and specifying the version to 3.0.0.

The command that I used:

dotnet tool install --global dotnet-ef --version 3.0.0

5
  • There is a closed issue report on it here: github.com/dotnet/EntityFramework.Docs/issues/2044
    – Moby Disk
    Commented Nov 4, 2020 at 19:31
  • 1
    FYI: 3.0.0 is the version of dotnet-ef
    – TimeTrap
    Commented Jan 14, 2021 at 14:13
  • 1
    Note that this is an old version of dotnet-ef. Current is 5.0.5.
    – ksingh
    Commented Apr 29, 2021 at 13:50
  • Why is this the case, having to directly specify the version?
    – enorl76
    Commented Jan 4, 2022 at 20:33
  • 2
    I'm using dotnet 6 and windows 11 but still dosen't work. <b>Command:</b> dotnet tool install --global dotnet-ef --version 6.0.4 Commented Apr 17, 2022 at 7:55
25

dotnet tool install -g dotnet-ef --ignore-failed-sources worked for me. Thanks to Anas-Alhariri

Source

1
  • 3
    Thanks a lot : best answer. With other commands, I had to uncheck custom package source before running commands. The parameter "--ignore-failed-sources" fix everything.
    – Nk54
    Commented Oct 1, 2021 at 13:34
4

I had the same issue on Mac OS recently. It was related to the fact that we use our own NuGet feed (packageSources section). So, I fixed that by removing the custom NuGet feed from NuGet.config file for a while.

1
  • This fixed it for me and I'm using Windows 10. I had to right click my project -> Manage NuGet Packages, then in the top right next to "Package Source" I clicked on the settings cogwheel symbol and made sure only nuget.org and Microsoft Visual Studio Offline Packages were selected. Commented Aug 21, 2021 at 7:05
4

If everything else failed then you should check in your Visual Studio the next route: Tools > NuGet Package Manager > Package Manager Settings > Nuget Package Manager > Package Sources. There you should have nuget.org, if not and you only have Microsoft Visual Studio Offline Packages, well that is the problem. Next you need to add the package resource nuget.org like this: enter image description here

Once you click Ok you can go back to your terminal and install dotnet-ef with no problem.

2

My way of dealing with this problem was that I downloaded the package directly from package source

and then specified an alternative source in the command

dotnet tool install --global dotnet-ef --version 7.0.2 --add-source "C:\nuget"
2
  • Why would that succeed if just installing it from NuGet wouldn't? BTW, the link is incorrect. Commented May 18, 2023 at 13:29
  • For some reason in my case it couldn't be installed from the web. There may be some kind of network problem on the corporate network. I had to download the package and install from a local folder. Yes the link is broken. My fault Commented May 19, 2023 at 14:33
0

I got this error message, but when I closely inspected all the errors I also had:

Response status code does not indicate success: 407 (Proxy Authorization Required).

Turning off the proxy while running the command fixed the issue.

0

I got this error when I tried to run the command from the Package Manager Console instead of a Powershell command window.

0

For some of reasons you can try to delete directory C:\Program Files\dotnet\sdk-manifests it will make you can download it.

.net 6 ref : https://github.com/dotnet/sdk/issues/23435

0

For an easy, one-step fix to this, try this command:

 dotnet tool install dotnet-counters --interactive --ignore-failed-sources --add-source https://api.nuget.org/v3/index.json

I found that the reason for the failure was very often a 401 unauthorized error, not being shown to the user.

The combination of --interactive will prompt for credentials if expired, while the -add-source instructs the dot net tool to look as well to a mainline package stream of nuget.org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.