[New article]: Entity Framework and .NET Aspire
Proposed topic or title
Use Entity Framework with .NET Aspire
Location in table of contents.
Integrations
Reason for the article
We have around 17 open issues that relate to EF and .NET Aspire, such as:
- Update instructions for "Add the migration service to the orchestrator" section #2430
- Question: Dotnet Aspire EF Migration on production #2368
- Missing documentation ClientConfiguration #2358
- Need to modify some of the migration service example codes #2357
I'm working on a new article to address as many of these as I can. Please let me know your thoughts by commenting on this issue.
The existing EF coverage consists of:
- Tutorial: Connect an ASP.NET Core app to SQL Server using .NET Aspire and Entity Framework Core
- Apply Entity Framework Core migrations in .NET Aspire
- Seed data using Entity Framework Core
- The articles about EF Integrations.
IMHO we need a new article to cover all these issues in depth, not a tutorial that only covers one scenario.
Article abstract
Topics to include:
- When to use Aspire's AddXDbContext() method for each integration
- When to use EnrichXDbContext() with examples using Interceptors
- DBContextFactories and whether to use them in Aspire
- Database context pooling in .NET Aspire. When is it good? How to use/not use it
- Database first, code first, model first in Aspire
- Migrations
- Workflow for applying migrations
- Why use a separate migrations service?
- Whether to use a transaction with each migration (not for v9)
- Troubleshooting tips
I think I'll include pivots for the four EF Integrations:
- SQL Server
- PostgreSQL
- MySQL Pomelo
- Oracle
Relevant searches
No response
@roji ~ we wondered if you have any comment on this proposed article? If so feel free, and I'll incorporate it as I write. Thanks!
/cc @AndriySvyryd who worked on the various Aspire-related migrations/seeding adjustments in EF 9.0, and who probably would be the best person to review/help out with guidance.
I'm not very familiar with Aspire's documentation and/or which level they go into, but the above looks great to me - deeper guidance on recommended patterns for Aspire and EF usage is something we've also discussed in the EF team, but haven't had bandwidth to look at. There's the usual question of where this lives - EF vs. Aspire docs - and how cross-linking between the two works; but I wouldn't worry about it too much, if a deep article on the Aspire side makes sense, we can simply link to it from the EF docs, at least for now.
#2666 covers using EF DB Contexts in .NET Aspire. I'm planning a separate article about migrations.
This looks good. Just make sure to include database seeding, there's a new pattern in EF9.
Also, consider adding a pivot for Cosmos