C#C
C#9mo ago
Cydo

✅ Can't update database in docker.

I'm very new to docker, but I've setup 2 Docker files one for my api and one for my client, and i can run them an access both but my database is always empty, and I can't run any ef commands to update or apply migrations and I have no idea why, it keeps saying I don't have the SDK but I'm almost positive in my Dockerfile I'm bringing in the SDK.

$ docker exec -it ripple-api dotnet ef migrations add InitialMigration
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'ef' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.


But from my understanding I have the docker file bringing in the SDK, so I don't understand how i cant run the commands...

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base

WORKDIR /app

EXPOSE 3000
EXPOSE 3001

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Development
WORKDIR /src

COPY . . 

RUN dotnet restore "Ripple.csproj"

COPY . . 

WORKDIR "/src"

RUN dotnet build "Ripple.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Development

RUN dotnet publish "Ripple.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app

COPY --from=publish /app/publish .

COPY ./app.db ./  

ENTRYPOINT ["dotnet", "Ripple.dll"]
Was this page helpful?