Con*_*ver 4 entity-framework command-line-interface .net-core
我正在尝试使用dotnet core 3 Preview 4开发一些WebAPI。dotnetcore及其库(例如EF core和Identity等)对我很熟悉。但是现在使用版本3 Preview 4,Microsoft.EntityFrameworkCore.Tools无法正常工作,并且该命令dotnet ef migrations add ...
告诉此消息:
找不到命令“ dotnet ef”,请运行以下命令进行安装
dotnet工具安装--global 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>
Run Code Online (Sandbox Code Playgroud)
而且我已经尝试dotnet tool install --global dotnet-ef
但没有解决我的问题。随着版本3预览版4的新发布,我在官方网站或第三方网站上找不到与此有关的任何文档。
Nis*_*nga 12
首先确保
dotnet --info
然后看到一行Run Code Online (Sandbox Code Playgroud).NET Core SDKs installed: 3.0.100-preview4-011223 [C:\Program Files\dotnet\sdk]
dotnet restore
了该项目cd
编辑到项目的(* .csproj)目录使用Entity Framework Core 3.0 Preview 4,dotnet-ef工具不再是.NET Core SDK的一部分。使用以下方法卸载dotnet-ef
工具的稳定版本(此时为2.2.4):
dotnet tool uninstall --global dotnet-ef
Run Code Online (Sandbox Code Playgroud)
然后安装预览,(检查版本)
dotnet tool install --global dotnet-ef --version 3.0.0-preview4.19216.3
Run Code Online (Sandbox Code Playgroud)
之后dotnet ef
应该可以正常工作。
.NET Core 3.0引入了本地工具:
本地工具类似于全局工具,但与磁盘上的特定位置关联。本地工具不在全球范围内提供,而是作为NuGet软件包分发。
dotnet核心以及EF核心都在快速发展。在不同的dotnet版本中拥有多个项目/解决方案很容易。使用本地工具,您可以按项目配置特定的版本工具。
按项目配置工具的步骤:
dotnet new tool-manifest
#executing this at sln level (or with your projecte) a new .config file is created
dotnet tool install --local dotnet-ef --version 3.0.0-preview4.19216.3
#this will configure dotnet ef tool
dotnet ef
#should run at this point
Run Code Online (Sandbox Code Playgroud)
此时,您的ef migrations / database命令必须运行。
归档时间: |
|
查看次数: |
3327 次 |
最近记录: |