Command dotnet ef not found
To install the dotnet-ef
tool, run the following command:
.NET 7
dotnet tool install --global dotnet-ef
.NET 6
dotnet tool install --global dotnet-ef --version 6.*
.NET 5
dotnet tool install --global dotnet-ef --version 5.*
.NET Core 3
dotnet tool install --global dotnet-ef --version 3.*
For more information about the history of dotnet-ef
, see the announcement for ASP.NET Core 3 Preview 4, which explains that this tool was changed from being built-in to requiring 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.
Cannot find command 'dotnet ef'
Note to readers: If you haven't installed dotnet ef
, you need to install it first: dotnet tool install --global dotnet-ef
. The question-asker already did that. You need to do that first before the rest of this answer can help.
How to fix this
For Linux and macOS, add a line to your shell's configuration:
bash
/zsh
:export PATH="$PATH:$HOME/.dotnet/tools/"
csh
/tcsh
:set path = ($path $HOME/.dotnet/tools/)
When you start a new shell/terminal (or the next time you log in) dotnet ef
should work.
For Windows:
See this question on how to add to the PATH
environment variable.
You need to add %USERPROFILE%\.dotnet\tools
to the PATH
.
What's going on?
The .NET Core 3.0 (preview) version of this failure is much more illuminating:
$ dotnet ef
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.
The second and the third one both refer to dotnet
trying to find a dotnet-ef
command but can't find it. As the third point says, dotnet-ef
is not in your path.
Here's what the docs say:
Global Tools can be installed in the default directory or in a specific location. The default directories are:
OS Path
Linux/macOS $HOME/.dotnet/tools
Windows %USERPROFILE%\.dotnet\tools
So, you should add $HOME/.dotnet/tools/
to your $PATH
.
But also note this part from docs:
These locations are added to the user's path when the SDK is first run, so Global Tools installed there can be called directly.
So, it sounds like something went wrong. If you installed using a manual tarball, the SDK screwed up and you should report this bug to Microsoft. If you use a distribution package, they screwed up and you should report this as a bug to them.
Cannot find command 'dotnet ef' (Powershell Core - LInux)
You probably need to install the ef
tool per https://learn.microsoft.com/en-us/ef/core/get-started/overview/install#get-the-net-core-cli-tools - try dotnet tool list
and if you can’t see it in the output then run this:
dotnet tool install --global dotnet-ef
And re the PATH
environment variable, you’re overwriting the value rather than appending your extra folder name, which is why the operating system can’t find other applications afterwards.
You probably intended something like
PS /home/> $env:PATH = $env:PATH + ‘;’ + ‘$HOME/.dotnet/tools'
dotnet ef command no longer works after upgrading to Visual Studio 16.3.0
This is a breaking change in Entity Framework Core 3.0:
The EF Core command-line tool, dotnet ef, is no longer part of the .NET Core SDK.
...
Starting in 3.0, the .NET SDK does not include the dotnet ef tool, so before you can use it you have to explicitly install it as a local or global tool.
You need to install the Entity Framework Core Tools. To install it globally, run this on the command line:
dotnet tool install --global dotnet-ef
dotnet-ef still not found after installation
The dotnet tool install
command requires elevation!
Related Topics
Xml Deserialization of Collection Property with Code Defaults
How to Group by on 2 Child Entities and Get Total of Both This Child Entities
Dependency Injection Type-Selection
Encoding Space Character in Xml Name
In-Use Files Not Updated by Msi-Installer (Visual Studio Installer Project)
Good Introduction to the .Net Reactive Framework
What Are the Differences Between Various Threading Synchronization Options in C#
How to Create a Message Box with "Yes", "No" Choices and a Dialogresult
What Does "Yield Break;" Do in C#
.Net Core Identity Server 4 Authentication VS Identity Authentication
When Would You Use Delegates in C#
Wpf Openfiledialog with the Mvvm Pattern
Auto Versioning in Visual Studio 2017 (.Net Core)
C# Passing Function as Argument