5

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?

SigGP
  • 716
  • 1
  • 11
  • 24
  • Not exactly. I get an error: dotnet-ef: command not found – SigGP Feb 08 '20 at 17:55
  • 3
    The problem was that there is a need to type ENV PATH="${PATH}:/root/.dotnet/tools" instead of RUN export PATH="$PATH:/root/.dotnet/tools" – SigGP Feb 08 '20 at 20:02
  • Great - if you think the other thread doesn't answer your question, you should put an answer here. :-) – Jeppe Feb 09 '20 at 11:29

2 Answers2

9

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"
Vočko
  • 2,478
  • 1
  • 23
  • 31
0

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"
harili
  • 406
  • 9
  • 24