-
Notifications
You must be signed in to change notification settings - Fork 697
Description
We've gotten feedback about missing EF scenarios - it started with Npgsql component doesn't allow configuration of the NpgsqlDbContextOptionsBuilder. We we fixed this by allowing to configure the DbContextOptionsBuilder
, but this had the problem that the user needed to call UseNpgsql
again to configure Npgsql specific options. Npgsql and SqlServer work this way, but CosmosDB doesn't - the UseCosmos API forces callers to pass a connection string, or other connection information.
Then more feedback came in that we don't support all the options that EF allows w.r.t. DependencyInjection:
- Add ability to configure NpgsqlDataSource #1276
- Please include AddSqlServerDbContextFactory #1241
- Add ability to modify the
ServiceLifetime
on AddSqlServerDbContext #1194 - [WebToolsE2E][Aspire]After adding 'Aspire.Npgsql.EntityFrameworkCore.PostgreSQL' component and updating related codes, F5 failed with an exception: 'Some services are not able to be constructed ...' #744 (the error happens because the scaffolding injects EF code into Program.cs)
Given all this feedback, and diving into the EF APIs, we think we need to redesign the Aspire EF component's public APIs. Today we are wrapping the EF APIs for Pooling or regular DbContext.
But instead, we should have the dev user call directly into the EF DependencyInjection APIs, so they have full control over what they want to add to the app. Then the Aspire EF Component can just have an extension method to add the other things:
- Health Checks
- Tracing
- Metrics
- Tracing
- Logging
- etc
The hard part will be coming up with the naming of that Aspire extension method. It can't be called AddNpgsqlDbContext
anymore, since it doesn't add the DbContext.