【发布时间】:2018-04-08 16:25:05
【问题描述】:
我已经阅读了过去 2 年发布的关于 EF 的几乎所有其他问题。我下载其他包没有问题,只有实体框架不会为我安装。
我什至尝试安装最新版本的 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://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet 说明您所要做的就是更改 .csproj 文件并使用 dotnet/nuget 包管理工具进行恢复,但这似乎对我的项目没有任何作用,并且 dotnet-ef.exe 仍然找不到.
【问题讨论】:
-
您使用的是 Visual Studio 的包管理器控制台还是 CLI?
-
我都试过了。唯一的区别是 PMC 似乎更冗长
-
PMC 和 CLI 是两个不同的环境,使用两个不同的包
标签: c# entity-framework .net-core entity-framework-core csproj