我已经阅读了过去两年中发布的与EF相关的几乎所有问题。 我没有遇到下载其他软件包的任何问题,只有Entity Framework无法安装。
我甚至尝试安装最新版本的Nuget,并在项目目录中使用其工具来还原软件包 - 在我添加此行到我的.csproj文件之后:
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
首先,我尝试了这个命令:
dotnet restore
生成以下输出:
C:\Path\To\My\Project>dotnet restore
Restore completed in 100.41 ms for C:\Path\To\My\Project\TestNuget.csproj.
Restore completed in 68.84 ms for C:\Path\To\My\Project\TestNuget.csproj.
并导致以下结果:
> dotnet ef
No executable found matching command "dotnet-ef"
因此,我尝试了这个(使用截至今天日期的最新版本的Nuget):
nuget restore Example.csproj
这会输出以下内容:
MSBuild auto-detection: using msbuild version '15.6.85.37198' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin'.
Committing restore...
Tool assets file has not changed. Skipping assets file write. Path: C:\Path\ToNuget\.nuget\packages\.tools\microsoft.visualstudio.web.codegeneration.tools\2.0.3\netcoreapp2.0\project.assets.json
Restore completed in 139.95 ms for C:\Path\To\User\source\repos\Example\Example\Example.csproj.
Committing restore...
Assets file has not changed. Skipping assets file writing. Path: C:\Path\To\User\source\repos\Example\Example\obj\project.assets.json
Restore completed in 113.51 ms for C:\Path\To\User\source\repos\Example\Example\Example.csproj.
NuGet Config files used:
C:\Path\To\User\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.Fallback.config
Feeds used:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
https://api.nuget.org/v3/index.json
这与原来的结果相同。
我不确定问题出在哪里,我在网上阅读的所有内容,包括https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet都指出,你只需要修改.csproj文件并使用dotnet/nuget包管理工具进行恢复,但是这似乎对我的项目毫无作用,而且dotnet-ef.exe仍然无处可寻。