Command dotnet ef not found
Solution 1:
See the announcement for ASP.NET Core 3 Preview 4, which explains that this tool is no longer built-in and requires an explicit install:
The dotnet ef tool is no longer part of the .NET Core SDK
This change allows us to ship
dotnet ef
as a regular .NET CLI tool that can be installed as either a global or local tool. For example, to be able to manage migrations or scaffold aDbContext
, installdotnet ef
as a global tool typing the following command:
dotnet tool install --global dotnet-ef
To install a specific version of the tool (see all available versions at nuget.org), use the following command:
dotnet tool install --global dotnet-ef --version 3.1.4
The reason for the change is explained in the docs:
Why
This change allows us to distribute and update
dotnet ef
as a regular .NET CLI tool on NuGet, consistent with the fact that the EF Core 3.0 is also always distributed as a NuGet package.
In addition, you might need to add the following NuGet packages to your project:
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Design
- Microsoft.EntityFrameworkCore.Tools
Solution 2:
If you are using a Dockerfile for deployments these are the steps you need to take to resolve this issue.
Change your Dockerfile to include the following:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
ENV PATH $PATH:/root/.dotnet/tools
RUN dotnet tool install -g dotnet-ef --version 3.1.1
Also change your dotnet ef
commands to be dotnet-ef