DI containers

A DI container follows the RRR (Register-Resolve-Release) pattern.

A DI container is a framework or a library used in order to compose the object graph of an application, creating a composition root at the application entry point and managing their lifetime. This composition root registers the objects and their abstractions that are to be resolved.

There are a lot of free DI containers, such as the following:

  • Unity
  • Ninject
  • StructureMap
  • Autofac
  • Simple Injector
  • DryIoc
  • And many others

When creating the composition root, we configure the DI container. We can do that by using code, but also by an XML configuration file if the DI container we chose has this functionality.

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.