mikebridge
mikebridge

Reputation: 4585

Any way to run dotnet-ef from a published app

I'm constructing a docker container from a Dotnet Core 2.0 WebApp that was packaged with dotnet publish, but publishing this way doesn't copy the extensions in Microsoft.EntityFrameworkCore.Tools.DotNet that enable the dotnet-ef command.

Specifically, I want to run dotnet ef commands in the container, but I get this error:

No executable found matching command "dotnet-ef"

My .csproj file contains this, so dotnet-ef works fine on the host:

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />

Is there a way to run migrations from a dotnet app that's been packaged with dotnet publish?

Upvotes: 0

Views: 1076

Answers (1)

mikebridge
mikebridge

Reputation: 4585

Based on @bricelam's suggestion and Ben Day's blog entry, this works for dotnet 2.x on Linux:

$ dotnet exec \
    --depsfile Api.deps.json \
    /usr/share/dotnet/sdk/NuGetFallbackFolder/microsoft.entityframeworkcore.tools.dotnet/2.0.2/tools/netcoreapp2.0/ef.dll \
    database update \
    --assembly ./MyDllWithMigrations.dll \
    --startup-assembly Api.dll \
    --project-dir . \
    --verbose

(This is based on the microsoft/aspnetcore-build base image.)

Upvotes: 1

Related Questions