When running `dotnet ef migrations add` from a .NET class library, you may encounter an 'Unable to resolve DbContextOptions' error. The fix is to implement `IDesignTimeDbContextFactory<T>`, a lesser-known EF Core interface that provides design-time services with the context configuration needed to generate migrations. This approach lets you centralize migration logic in one project while still allowing consuming projects to configure connection strings, providers, and logging options at runtime.

3m read timeFrom khalidabuhakmeh.com
Post cover image
Table of contents
Dependencies and ceremonyIDesignTimeDbContextFactory to the rescueConclusion
2 Impressions