Skip to content

EnrichSqliteDatabaseDbContext registers DbContext #1269

@DavidGarton8

Description

@DavidGarton8

Describe the bug

EnrichSqliteDatabaseDbContext does not follow the expected Aspire Enrich... pattern. Instead of enriching an already registered DbContext, it registers the DbContext itself.
This makes its behavior inconsistent with the corresponding Aspire extensions, where Enrich... methods apply cross-cutting configuration such as telemetry and health checks to an existing registration rather than creating one.

Regression

N/A

Steps to reproduce

1. Create an application builder.
2. Do not register the DbContext.
3. Call EnrichSqliteDatabaseDbContext<TDbContext>().
4. Build the application and resolve the DbContext.

Expected behavior

EnrichSqliteDatabaseDbContext should require the DbContext to already be registered.
If the DbContext has not been registered, the method should throw an InvalidOperationException. If it has been registered, the method should only apply enrichment behavior such as telemetry and health checks.

Screenshots

No response

IDE and version

Rider

IDE version

2026.1

Nuget packages

CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions