EF Core "Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design" in CI
The dotnet ef tool needs the Microsoft.EntityFrameworkCore.Design package in the startup project to load design-time services. Without it, migrations and database commands stop before doing anything.
What this error means
A dotnet ef command fails with "Your startup project 'X' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work."
Your startup project 'MyApp.Web' doesn't reference Microsoft.EntityFrameworkCore.Design.
This package is required for the Entity Framework Core Tools to work. Ensure your
startup project is correct, install the package, and try again.Common causes
The Design package is not referenced
The startup project has no PackageReference to Microsoft.EntityFrameworkCore.Design, which the tools need to build the migration model.
The wrong startup project is targeted
The command runs against a class library or a project that lacks the Design reference instead of the web/host project that has it.
How to fix it
Add the Design package to the startup project
- Add a reference to
Microsoft.EntityFrameworkCore.Designin the host/web project. - Restore so the package is present before running
dotnet ef. - Re-run the migration command.
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
</PackageReference>Point --startup-project at the right project
If the DbContext lives in a library, tell the tool which project is the startup project and which holds the context.
dotnet ef migrations add Init \
--project src/MyApp.Data \
--startup-project src/MyApp.WebHow to prevent it
- Reference Microsoft.EntityFrameworkCore.Design in the startup/host project.
- Use --project and --startup-project explicitly when the context is in a library.
- Keep the Design package version aligned with the EF Core runtime version.