Explain Dependency Injection lifetimes in .NET Core

Updated Apr 28, 2026

Short answer

DI lifetimes define how long a service instance lives: Singleton, Scoped, and Transient.

Deep explanation

Singleton creates one instance for the entire application lifetime. Scoped creates one instance per HTTP request. Transient creates a new instance every time it is requested. Choosing the correct lifetime is critical for performance, memory management, and avoiding threading issues.

Real-world example

DbContext is typically registered as Scoped to ensure one instance per request.

Common mistakes

  • Injecting scoped services into singleton
  • using singleton for non-thread-safe services.

Follow-up questions

  • What happens if a scoped service is injected into a singleton?
  • When should you use transient services?

More .NET Core interview questions

View all →