给.net core 3.1.1安装ef时报错,如下
-> dotnet tool install --global dotnet-ef
error NU1100: Unable to resolve 'dotnet-ef ' for '.NETCoreApp,Version=v3.1'.
error NU1100: Unable to resolve 'dotnet-ef ' for '.NETCoreApp,Version=v3.1/any'.
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.
网上找了半天,终于找到解决办法:
1. 将C:\Users\<user>\AppData\Roaming\NuGet文件夹下的NuGet.Config删除
2.在项目文件夹下运行命令:dotnet restore。将会生成新的NuGet.Config文件,其中packageSources的值不同,旧的为https://www.nuget.org/api/v2/
新的为
https://api.nuget.org/v3/index.json
正是这个差异导致相关下载失败。
之后再运行相关命令行就可以正常下载了。