Coder Perfect

Command dotnet ef not found

Problem

In order to generate a first migration, I’m following the documentation. I get the help section when I run dotnet, indicating that the PATH is correct.

Then I try to run the following command from the docs in the terminal window:

The following error appears:

I’m googling the problem, but there’s not much to go on because the version is new, and/or it’s drowning in similar difficulties from previous versions.

I attempted to install Microsoft.EntityFrameworkCore via force, just in case it was required. I received an error message stating that the most recent version available is 2.2.6 and that downgrading is not an option. I’m not sure how to install the version that’s compatible with the SQL-package I already have (and even less sure if that’s the best way to solve this problem).

Asked by Konrad Viltersten

Solution #1

This tool is no longer built-in and requires an extra install, according to the announcement for ASP.NET Core 3 Preview 4, which explains:

dotnet tool install --global dotnet-ef

Use the following command to install a specific version of the program (see all available versions at nuget.org):

dotnet tool install --global dotnet-ef --version 3.1.4

The documentation explains why the change was made:

You may also need to include the following NuGet packages in your project:

Answered by Kirk Larkin

Solution #2

These are the steps you must do to remedy this issue if you are utilizing a Dockerfile for deployments.

Include the following in your Dockerfile:

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

Change your dotnet ef commands to dotnet-ef as well.

Answered by Nick Spicer

Solution #3

Troubleshoot difficulties with.NET Core tool usage.

Answered by Gambitier

Solution #4

I was able to resolve this issue by using the following commands to install the dotnet-f utility locally.

If you’re the one who’s going to set up this repository,

dotnet new tool-manifest

dotnet tool install --local dotnet-ef --version 5.0.6

Then instead of dotnet-ef, use dotnet dotnet-ef.

Answered by 2 revs, 2 users 78%

Solution #5

For those using MinGW MSYS with the.NET Core CLI:

After installing using

dotnet tool install --global dotnet-ef

This line should be added to the bashrc file (C:msys64homeusername -.bashrc) (the location depends on your setup)

export PATH=$PATH:/c/Users/username/.dotnet/tools

Answered by thebennies

Post is based on https://stackoverflow.com/questions/57066856/command-dotnet-ef-not-found