I can't figure out how to manually update the database (without a workaround) in a .net Aspire app using Entity Framework Core. The issue is similar to this one, but my question is different:
In my AppHost, I spin up a PostgesDB and pass a reference to the project myApp, where I add the DB context builder.AddNpgsqlDbContext<MyDbContext>("myDB"). I can manually apply migrations using dotnet ef migrations add Init --project myApp and updating the data base programmatically as described here kind of works.
When I try manually updating the database with dotnet ef database update --project myApp I get System.ArgumentException: Host can't be null, which is clear, because AppHost is not running, so there is no DB container. I found this workaround works when using the --no-build option (otherwise the app locks some files that need to be updated during build), but it's a workaround.
However, I expected that I could spin up the AppHost by additionally specifying the startup project like dotnet ef database update --project myApp --startup-project AspireDB.AppHost. But now I get Could not load assembly 'myApp'. Ensure it is referenced by the startup project 'AspireDB.AppHost', which puzzles me, as the app works when I run it, so there is a reference to myApp.
Why does --startup-project not work as I expect?