Skip to content
LatchkeyLatchkey home

EF Core "dotnet ef" command not found in CI

A step ran dotnet ef ... but the dotnet-ef global (or local) tool is not installed on the runner. Install the tool before running any migration or database command in CI.

What this error means

A migration step fails with "Could not execute because the specified command or file was not found." naming dotnet-ef, or "No executable found matching command \"dotnet-ef\"".

.NET
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * ... the tool 'dotnet-ef' does not exist.
No executable found matching command "dotnet-ef".

Diagnose it: SDK version and restore first

Most .NET CI failures are an SDK mismatch or a restore that did not happen. global.json pins the SDK, and if the runner does not have that exact version the failure message is about the project rather than the SDK.

Terminal
dotnet --info
cat global.json 2>/dev/null

# restore explicitly so a restore failure is not reported as a build failure
dotnet restore --verbosity normal
dotnet build --no-restore -warnaserror

Common causes

The dotnet-ef tool is not installed

A clean runner has no global tools. dotnet ef is a separate .NET tool that must be installed explicitly, unlike built-in commands such as dotnet build.

A local tool manifest was not restored

If you use a dotnet-tools.json manifest, dotnet tool restore must run first, otherwise the local dotnet ef is unavailable.

How to fix it

Install the EF Core global tool

  1. Install dotnet-ef as a global tool in a step before migrations.
  2. Ensure the tools directory is on PATH (setup-dotnet adds ~/.dotnet/tools).
  3. Pin the tool version to match your EF Core package version.
.github/workflows/ci.yml
- run: dotnet tool install --global dotnet-ef --version 8.0.*
- run: dotnet ef database update

Restore a local tool manifest

If EF is pinned in a manifest, restore it and invoke via dotnet ef (or dotnet tool run dotnet-ef).

Terminal
dotnet tool restore
dotnet ef migrations list

How to prevent it

  • Install or restore dotnet-ef in a dedicated step before any migration command.
  • Pin the tool version to the EF Core version to avoid provider mismatches.
  • Prefer a committed dotnet-tools.json manifest so the version is reproducible.

Frequently asked questions

What causes EF core "dotnet ef" command not found in CI?
There are 2 common causes: the dotnet-ef tool is not installed and a local tool manifest was not restored. A clean runner has no global tools.
How do I fix EF core "dotnet ef" command not found in CI?
There are 2 fixes depending on which cause you have: install the ef core global tool and restore a local tool manifest. Work through them in order, since the first is the most common.
What does EF core "dotnet ef" command not found in CI actually mean?
A migration step fails with "Could not execute because the specified command or file was not found." naming dotnet-ef, or "No executable found matching command \"dotnet-ef\"".
How do I stop EF core "dotnet ef" command not found in CI happening again?
Install or restore dotnet-ef in a dedicated step before any migration command. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card