Enable Javascript

Please enable Javascript to view website properly

Toll Free 1800 889 7020

Looking for an Expert Development Team? Take two weeks Trial! Try Now

In-built Dependency Injection in .NET Core 3.1

Agenda

In this article, we will learn about the in-built dependency injection IOC (Inversion of Control) container that comes out of the box with .net core development. This eliminates the use of external IOC Containers like AutoFac, Unity, etc.

Pre-requisite:

The built-in container offers Constructor and method injection only. Property injection is not supported as of now, which can be achieved using third party containers like AutoFac, unity etc.

In-built container manages the classes and their implementations in the form of services which can be divided into two parts:

Lifetime of registered services: There are three types of registrations that are provided with IOC container of .net core. These registrations define the lifetime of the dependencies.

We will see all of them in action later in this article.

Extension methods: For all the three registration types mentioned above, .net core offers extension methods which makes it easy to register the objects in the container.

1. AddTransient() 2. AddScoped() 3. AddSingleton()

Enough information. Now, let’s see the demo.

Software Development Team
Need Software Development Team?
captcha
🙌

Thank you!
We will contact soon.

Oops! Something went wrong.

Recent Blogs

Categories

NSS Note
Some of our clients
team