EF Core "dotnet ef migrations bundle" failures in CI
A migrations bundle packages your migrations into a self-contained executable to apply in a later step or environment. It fails when the target runtime is wrong, the Design package is missing at build, or no connection string is passed when running the bundle.
What this error means
Building the bundle errors, or running ./efbundle fails with a connection error because no connection string was provided, or a "RID" / runtime mismatch when the bundle runtime differs from the runner.
Building bundle...
An error occurred while accessing the Microsoft.Extensions.Hosting services.
No connection string named 'Default' was found and no connection was supplied.Common causes
No connection string passed to the bundle
The bundle needs a connection at apply time. Without --connection or a config source, it cannot reach the database.
A runtime or Design mismatch at build time
Building for a --self-contained runtime that does not match the runner, or a startup project missing the Design package, breaks the bundle build.
How to fix it
Build the bundle then apply with a connection
- Build the bundle in one step, targeting the runtime that will run it.
- Run the produced
efbundleand pass the connection string. - Supply the connection from a secret, not a committed file.
dotnet ef migrations bundle --self-contained -r linux-x64 -o efbundle
./efbundle --connection "$ConnectionStrings__Default"Ensure the Design package and startup project
The bundle build uses the same design-time services as other ef commands, so the startup project must reference Microsoft.EntityFrameworkCore.Design.
How to prevent it
- Pass the connection string to efbundle at apply time from a CI secret.
- Match the bundle runtime identifier to the runner or deploy target.
- Keep the Design package in the startup project used to build the bundle.