Lamar is an open-source .NET dependency-injection and inversion-of-control container. It replaces ASP.NET Core’s built-in container when simple service registration becomes limiting, while preserving the framework’s service-registration model. section 31.0 section 31.3
Install Lamar.Microsoft.DependencyInjection, call UseLamar on the application host, and register framework services through Lamar’s ServiceRegistry. AddControllersAsServices ensures Lamar builds API controllers.
Lamar adds capabilities that are useful as an application grows:
- Assembly scanning registers services by convention. section 31.3
- Automatic concrete-class registration reduces explicit registrations. section 31.3
- Property injection, constructor selection, Lazy<T>, and Func<T> resolution extend container behavior. section 31.3
- Debugging and testing tools help inspect the container. section 31.3
