DI Container Fundamentals
Understand inversion of control, service registration, and how the .NET DI container resolves dependencies.
What Is Dependency Injection?
Dependency Injection (DI) is a design pattern where a class receives its dependencies from an external source rather than creating them itself.
Instead of writing var repo = new UserRepository(); inside a class, the class declares what it needs and the DI container provides it.
Inversion of Control
DI is a concrete implementation of the Inversion of Control (IoC) principle: the control of creating dependencies is inverted from the dependent class to an external container.
This makes classes easier to test and replace.