Any way to run dotnet-ef from a published app

.net-core c# docker entity-framework-core

Question

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?

1
0
3/16/2018 5:11:41 PM

Accepted Answer

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.)

1
3/19/2018 5:45:33 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow