我正在尝试使用dotnet 3预览4开发一些web API。我熟悉dotnet及其库,如EF核和标识等。但是现在使用版本3预览4,Microsoft.EntityFrameworkCore.Tools无法工作,dotnet ef migrations add ...命令告诉我们这样的信息:
找不到命令“dotnet”,请运行以下命令来安装 dotnet工具安装--全局dotnet-ef
csproj文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview4.19216.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview4.19216.3"/>
</ItemGroup>
</Project>我也尝试过dotnet tool install --global dotnet-ef,但没有解决我的问题。由于版本3预览4是新公布的,我找不到任何有关这方面的正式或第三部分网站的文档。
发布于 2019-05-03 22:51:12
编辑:
此时dotnet核心3不再预览,因此相应选择我们的版本。(校验版本)
首先要确保
dotnet --info并看到有一行类似,安装的.NET核心sdk: 3.0.100-preview4-011223 C:\Program \dotnet\sdk
dotnet restorecd编辑到项目的(*.csproj)目录使用EntityFrameCore3.0预览4,dotnet工具不再是.NET Core的一部分。卸载dotnet-ef工具的稳定版本(目前为2.2.4),
dotnet tool uninstall --global dotnet-ef然后安装预览版或最新版本,(校验版本)
dotnet tool install --global dotnet-ef --version 3.0.0-preview4.19216.3在那之后,dotnet ef应该可以正常工作。
发布于 2019-05-06 12:19:51
.NET Core3.0介绍了本地工具
本地工具与全局工具相似,但与磁盘上的特定位置相关联。本地工具不是全局可用的,而是作为NuGet包分发的。
dotnet Core和EF Core也在快速发展。在不同的dotnet版本上很容易有几个项目/解决方案。使用本地工具,您可以通过项目配置特定的版本工具。
按项目配置工具的步骤:
dotnet new tool-manifest
#executing this at sln level (or with your projecte) a new .config file is created
#check lasts versions at:
#https://www.nuget.org/packages/dotnet-ef/
dotnet tool install --local dotnet-ef --version 3.1.4
#this will configure dotnet ef tool
dotnet ef
#should run at this point此时,您的ef迁移/数据库命令必须运行。
当人们克隆你的回购应该运行:
dotnet tool restore发布于 2019-05-03 18:20:37
dotnet tool install -g dotnet-ef --version 3.0.0-preview4.19216.3https://stackoverflow.com/questions/55974734
复制相似问题