[c#] dotnet ef not found in .NET Core 3

I'm following the docs in order to create an initial migration. When I execute dotnet, I get the help section, meaning that the PATH works properly.

Then I try to execute the command below from the docs in console window:

dotnet ef migrations add InitialCreate  

I get the following error:

Could not execute because the specified command or file was not found.  
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.  
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
  • I excluded the first item since I copied the command.
  • I excluded the second item because the package Microsoft.EntityFrameworkCore.SqlServer is installed.
  • I excluded the third item because I get the help section when invoking dotnet.

I'm googling the issue but since the version is new, there's not much to go on and/or it's drowning in similar issues from earlier versions.

I tried to forcibly install Microsoft.EntityFrameworkCore just in case it needs to be explicitly added. I ran into the error message telling me that the latest version to pick from is 2.2.6 and a downgrade is a no-go. I'm not sure how to install the version compatible with the SQL-package I have on my system already (and even less certain if that's right approach to kill this issue).

Detected package downgrade: Microsoft.EntityFrameworkCore from 3.0.0-preview6.19304.10 to 2.2.6. Reference the package directly from the project to select a different version.
Web ->
Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview6.19304.10 ->
Microsoft.EntityFrameworkCore.Relational 3.0.0-preview6.19304.10 ->
Microsoft.EntityFrameworkCore (>= 3.0.0-preview6.19304.10)
Web -> Microsoft.EntityFrameworkCore (>= 2.2.6)

The answer is


For everyone using .NET Core CLI on MinGW MSYS. After installing using

dotnet tool install --global dotnet-ef

add this line to to bashrc file c:\msys64\home\username\ .bashrc (location depend on your setup)

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

I had the same problem. I resolved, uninstalling all de the versions in my pc and then reinstall dotnet.


if your using snap package dotnet-sdk on linux this can resolve by updating your ~.bashrc / etc. as follows:

#!/bin/bash
export DOTNET_ROOT=/snap/dotnet-sdk/current
export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks
export PATH="${PATH}:${DOTNET_ROOT}"
export PATH="$PATH:$HOME/.dotnet/tools"

Run PowerShell or command prompt as Administrator and run below command.

dotnet tool install --global dotnet-ef --version 3.1.3


EDIT: 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


Global tools can be installed in the default directory or in a specific location. The default directories are:

  • Linux/macOS ---> $HOME/.dotnet/tools

  • Windows ---> %USERPROFILE%\.dotnet\tools

If you're trying to run a global tool, check that the PATH environment variable on your machine contains the path where you installed the global tool and that the executable is in that path.

Troubleshoot .NET Core tool usage issues


I was having this problem after I installed the dotnet-ef tool using Ansible with sudo escalated previllage on Ubuntu. I had to add become: no for the Playbook task, then the dotnet-ef tool became available to the current user.

  - name: install dotnet tool dotnet-ef
    command: dotnet tool install --global dotnet-ef --version {{dotnetef_version}}
    become: no

For me, The problem was solved after I close Visual Studio and Open it again


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net-core

dotnet ef not found in .NET Core 3 How to use Bootstrap 4 in ASP.NET Core ASP.NET Core - Swashbuckle not creating swagger.json file Getting value from appsettings.json in .net core .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Automatically set appsettings.json for dev and release environments in asp.net core? Get ConnectionString from appsettings.json instead of being hardcoded in .NET Core 2.0 App Unable to create migrations after upgrading to ASP.NET Core 2.0 EF Core add-migration Build Failed ASP.NET Core form POST results in a HTTP 415 Unsupported Media Type response

Examples related to .net-core

dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Assets file project.assets.json not found. Run a NuGet package restore Is ConfigurationManager.AppSettings available in .NET Core 2.0? How to update record using Entity Framework Core? Using app.config in .Net Core EF Core add-migration Build Failed Build .NET Core console application to output an EXE What is the difference between .NET Core and .NET Standard Class Library project types? Where is NuGet.Config file located in Visual Studio project?

Examples related to entity-framework-core

dotnet ef not found in .NET Core 3 How to update record using Entity Framework Core? Unable to create migrations after upgrading to ASP.NET Core 2.0 Error: the entity type requires a primary key Entity Framework Core: DbContextOptionsBuilder does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver' auto create database in Entity Framework Core Entity Framework Core add unique constraint code-first How to unapply a migration in ASP.NET Core with EF Core The term "Add-Migration" is not recognized Auto-increment on partial primary key with Entity Framework Core

Examples related to .net-core-3.0

dotnet ef not found in .NET Core 3