Managing EF Core migrations in a .NET Aspire distributed solution requires bridging development-time tooling with runtime execution. The approach involves creating an IDesignTimeDbContextFactory implementation inside the AppHost project, referencing the Data project with IsAspireProjectResource set to false, and running the EF Core CLI with the appropriate --project and --startup-project flags. This lets the EF Core tooling spin up the Aspire dependency graph long enough to generate migration files without needing a persistent database.
Table of contents
The Solution StructureEntity Framework Core Design Time FactoryEF Core CLI CommandConclusion4 Impressions