What is Dependency Injection in .NET Core?

Updated Feb 20, 2026

Short answer

Dependency Injection (DI) is a design pattern used to achieve loose coupling by injecting dependencies into classes instead of creating them manually.

Deep explanation

.NET Core has a built-in IoC container. Services are registered in Program.cs and injected via constructors. It supports three lifetimes:

  • Transient
  • Scoped
  • Singleton

Real-world example

Injecting a database repository into a controller instead of instantiating it manually.

Common mistakes

  • - Incorrect service lifetime usage
  • - Injecting scoped into singleton

Follow-up questions

  • How would you scale this?
  • What are trade-offs?

More .NET Core interview questions

View all →