SigGP
SigGP

Reputation: 776

Using dotnet-ef with docker and asp.net core 3.1

I'm trying to run my application written in asp.net core 3.1 on docker. I need to create database using migrations. While executing dotnet ef database update; command I get:

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.

As I understand I need to install dotnet-ef tool. What is a correct way to do it in the container?

Upvotes: 7

Views: 8607

Answers (2)

harili
harili

Reputation: 477

It's maybe you didn't installed the EF tools :

dotnet tool install --global dotnet-ef

And added the Environment PATH as @Vočko suggested :

ENV PATH="$PATH:/root/.dotnet/tools"

Upvotes: 1

Vočko
Vočko

Reputation: 2986

Like @harili said, you have to install it and additionally add it to the PATH environment variable.

From Dockerfile:

RUN dotnet tool install --global dotnet-ef
ENV PATH="$PATH:/root/.dotnet/tools"

Upvotes: 11

Related Questions