Skip to content

DbContextCheck should work together with IDbContextFactory #33344

Open
@meggima

Description

@meggima

Is your feature request related to a problem? Please describe.

We use the services.AddDbContextCheck<AppDbContext>() method to monitor the connection to the database in our apps. Due to performance reasons we switched to using IDbContextFactory to access instances of EF Core DbContext:

services.AddPooledDbContextFactory<AppDbContext>(dbContextOptions)

When we did so, we noticed that the DbContextHealthCheck does not support the factory and, thus, we had to register the DbContext directly to keep the HealthCheck working:

// This is just required for the HealthCheck, since it does not (yet?) work with the Factory.
services.AddDbContextPool<AppDbContext>(dbContextOptions);

Describe the solution you'd like

The DbContextHealthCheck should support IDbContextFactory without any additional service registrations.

Additional context

We are willing to invest some time to implement this and submit a pull request. But we need some support on how we should implement this and how the API should look like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-healthchecksIncludes: Healthchecks (some bugs also in Extensions repo)enhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions