Summary
This chapter introduced you to the concepts of DI, which helps to write loosely coupled, more-testable, and more-readable code. This chapter covered the types of DI and how they are supported in ASP.NET Core 5. We have also seen how object lifetime is managed with different types of registrations. This chapter also introduced you to some of the popular third-party IoC containers available to further explore. We will be using the concepts learned in this chapter to build our e-commerce application. In Chapter 15, Testing, we will also see how DI can help with testability.
As recommended in Chapter 1, Designing and Architecting the Enterprise Application, under the Separation of concerns/single responsibility architecture section, we will always try to have services registered via interfaces. This will help with changing the concrete implementation at any time without changing the client implementation.
In the next chapter, we will learn how to configure .NET 5 and also...