How to use IDbContextFactory<T> from a singleton service in Blazor

A singleton cannot inject a DbContext, but it can inject IDbContextFactory , because AddDbContextFactory registers the factory as a singleton by default. Create and dispose one context per call, never cache the instance.