I am trying to develop some web APIs using dotnet core 3 preview 4. I am familiar to dotnet core and its libraries like EF core and Identity and etc. But now with the version 3 preview 4, Microsoft.EntityFrameworkCore.Tools does not work and the command dotnet ef migrations add ...
tells this message:
Cannot find command 'dotnet ef', please run the following command to install
dotnet tool install --global dotnet-ef
the csproj file is like this:
<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>
and also I have tried dotnet tool install --global dotnet-ef
but not solved my issue. As the version 3 preview 4 is newly announced, I can't find any documentation about this on official or third-part sites.
EF Core 5.0 requires a . NET Standard 2.1 platform. This means EF Core 5.0 will run on . NET Core 3.1 or .
Possible reasons for this include: You misspelled a built-in dotnet command. You intended to execute a . NET Core program, but dotnet-ef does not exist.
Update the tools Use dotnet tool update --global dotnet-ef to update the global tools to the latest available version. If you have the tools installed locally in your project use dotnet tool update dotnet-ef . Install a specific version by appending --version <VERSION> to your command.
.NET Core 3.0 introduces Local Tools:
Local tools are similar to global tools but are associated with a particular location on disk. Local tools aren't available globally and are distributed as NuGet packages.
dotnet Core and, also, EF Core, are evolving fast. It's easy to have several projects/solutions at different dotnet versions. With Local Tools you can configure specific version tools by project.
Steps to configure tool by project:
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
At this point your ef migrations/database command must runs.
When people clone your repo should run:
dotnet tool restore
Edit:
At this point dotnet core 3 is no longer preview, so select our version accordingly. (Check version)
First make sure that,
dotnet --info
and see there's a line like,.NET Core SDKs installed: 3.0.100-preview4-011223 [C:\Program Files\dotnet\sdk]
dotnet restore
on the projectcd
ed to the project's (*.csproj) directoryWith Entity Framework Core 3.0 Preview 4, dotnet-ef tool is no longer part of the .NET Core SDK. Uninstall the stable version of dotnet-ef
tool (2.2.4 at this point) using,
dotnet tool uninstall --global dotnet-ef
Then install the preview or latest stable, (Check version)
dotnet tool install --global dotnet-ef --version 3.0.0-preview4.19216.3
After that dotnet ef
should work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With