What is the purpose of OwningComponentBase, and how does it help manage the lifetime of dependencies within a specific component?

Last updated 5 July 2026

  • OwningComponentBase gives a component its own private DI scope (exposed as ScopedServices), so scoped services like a DbContext are disposed with the component instead of living for the whole Blazor Server circuit.

  • OwningComponentBase<T> adds a ready-resolved Service property of type T from that owned scope.

  • Don't use [Inject] for services you want component-scoped, because it resolves from the circuit's scope, not the owned one.

  • https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-10.0
  • https://chrissainty.com/an-introduction-to-owningcomponentbase/
  • https://blazor-university.com/dependency-injection/component-scoped-dependencies/owningcomponentbase-generic/
  • https://blazor-university.com/dependency-injection/component-scoped-dependencies/owning-multiple-dependencies-the-wrong-way/
  • https://blazor-university.com/dependency-injection/component-scoped-dependencies/owning-multiple-dependencies-the-right-way/
All Blazor interview questions