Dependency injection support with .NET Core

Microsoft has now supplied support for dependency injection directly with .NET Core in the form of extensions with the Microsoft.Extensions.DependencyInjection NuGet package. The support for DI in .NET Core is in a way that you can either use the provided DI implementation, or you can use given DI interfaces in Microsoft.Extensions.DependencyInjection.Abstractions and use it with the DI framework implementation of your choice, for example, Ninject.

Just to give you an idea of the .NET Core direction, a similar behavior or style is also designed with a logging framework in .NET Core using the Microsoft.Extensions.Logging.Abstractions package.

Let's look at an example to see the Microsoft DI in motion ...

Get Enterprise Application Architecture with .NET Core 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.