Aspire + EF Core
Anyone playing around with Aspire?
I want to like it but I'm having a hard time coming up with a sane way to manage the database in Aspire.
1. I dont think the database is persistent between coding sessions which means I have to run a migration each time I bring up the app
2. I cant seem to specify a connection string when running
dotnet ef database update --project <my_proj> --connection "conn str"
it just wigs out about a empty connection string. Since the connection string is ephemeral and changes between runs, I cant really throw it in appsettings.json
without needing to tweak it each time I restart the project
Anyone run into these things and find a sane workaround?4 Replies
You can apply migrations from code
Applying Migrations - EF Core
Strategies for applying schema migrations to production and development databases using Entity Framework Core
I saw that and got really excited till I saw this
If multiple instances of your application are running, both applications could attempt to apply the migration concurrently and fail (or worse, cause data corruption).I’m relatively new to .net tbh so I’m wondering if this is a major thing I should be worried about or if this is a somewhat rare occurrence in the grand scheme of things
in development you won't have multiple instances running
and in production your database will be persistent and you can do the migrations manually instead of at runtime