Dependency Injection (DI) is built into modern .NET — the framework includes a DI container that automatically constructs classes and injects their dependencies. You register services (mapping interfaces to implementations) and the container resolves them, enabling loosely-coupled, testable code. It's foundational to ASP.NET Core.
Registering services
// in Program.cs — register services with a LIFETIME
builder.Services.AddScoped<IUserRepository, UserRepository>();
builder.Services.AddSingleton<ICacheService, CacheService>();
builder.Services.AddTransient<IEmailSender, EmailSender>();
