Dependency injection is the basic building block of ASP.NET Core. This chapter shows how you can use dependency injection in order to resolve the dependencies of the classes inside an ASP.NET Core application. It also describes how you can deal with the dependency injection life cycle, and it provides some examples of how to keep the classes loosely coupled. The first part of this chapter will give you some basic theoretical ideas about dependency injection, while the second part will show you how to use it in any ASP.NET Core project.
This chapter will cover the following topics:
- What is dependency injection?
- Why implement the dependency injection pattern in real-world applications?
- Overview of the dependency injection life cycle
- How to implement dependency injections in ASP.NET Core