
Master dependency injection in .NET 5 and .NET Core by exploring the built-in ASP.NET core, covering basics to advanced concepts, and learn how to register services to build powerful applications.
Explain the basics and benefits of dependency injection in dotnet core, compare building with and without DI, and cover service lifetimes and injecting into actions, views, middlewares, and constructors.
Access the project resources and Github code on bhrugen.com, download the code, review lecture-specific changes, and preview dependency injection basics in the next video.
Discover how ASP.NET Core uses dependency injection and an inversion of control container. Register dependencies once, and let the container create, inject, and dispose them into pages.
Explore how dependency injection underpins ASP.NET Core, its role as a form of inversion of control, and how the built-in service container provides framework and application services via constructor injection.
learn the essential tools for this dependency injection course: Visual Studio 2019 or preview, SQL Server 2017–2019, and the latest .NET 5.
Create a new ASP.NET Core MVC web app in Visual Studio 2019 with individual authentication to support dependency injection. Install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation and enable AddRazorRuntimeCompilation in Startup.cs.
Understand why dependency injection matters by illustrating a non-DI scenario, creating a market condition enum and a market forecaster service in an ASP.NET Core home controller.
Demonstrate a non di setup in .NET 5 by wiring a market forecaster to a home view model and displaying a market forecast on the index view before dependency injection.
Explore the problems of tight coupling without dependency injection using a market forecaster example, and see how injecting dependencies lets you swap implementations and simplify testing.
Extract to interface reduces strong coupling through interface extraction, enabling Imarket forecaster implementations, market forecaster and market forecaster V2, to be used by the home controller via the interface.
Showcases constructor dependency injection by injecting IMarketForecaster into the home controller via a private field, with the IOC container registering the service and managing objects.
Register the market forecaster service in startup.cs via the dependency injection container, using add transient for Imarket forecaster and its market forecaster implementation; enable easy testing.
Explore framework services in ASP.NET Core, including IWebHostEnvironment, ILogger, IHttpContextFactory, IOptions, IStartup, and IApplicationBuilderFactory, and distinguish them from application services via dependency injection.
Demonstrate configuring app settings with IOptions and dependency injection by creating AppSettings classes for stripe, twilio, sendgrid, and forecast, and exposing settings from appsettings.json.
Configure the app settings container by registering the WazeForecastSettings, Stripe, SendGrid, and Twilio sections with the GetSection extension and services.Configure, enabling IOptions and injection into the home controller.
Inject app settings with IOptions in the home controller, bind stripe, Twilio, SendGrid, and WazeForecast settings, expose values via respective .Value properties, and render them in AllConfigSettings.
Refactor startup by moving app settings registration into a dedicated DI_Config class and an extension method, keeping startup.cs concise and maintainable.
Learn how the built-in dependency injection container in ASP.NET Core manages service lifetimes: singleton, scoped, and transient, with examples showing per-application, per-request, and per-injection instances.
Illustrate transient, scoped, and singleton lifetimes by creating three Guid services. Register them in the container and build a simple custom middleware that uses these services on each request.
Create a custom middleware that injects transient, scoped, and singleton services into HttpContext. It stores their GUIDs in context.Items and forwards the request to the next middleware.
Add a lifetime controller to demonstrate dependency injection lifetimes in .NET 5, wire transient, scoped, and singleton services, compare their guids via middleware and constructor, and register them in startup.
See how transient, scoped, and singleton lifetimes behave in dependency injection by comparing instances in a .NET Core app, using middleware and the lifetime controller.
Learners can leave and edit reviews to provide feedback that shapes content and guides future lessons, using the top nav to leave a rating and comment.
Explore constructor and action injection in ASP.NET Core by moving services from constructors to actions using from services inside actions, including IOptions for stripe and sendGrid, and validate application settings.
Explore how middleware injection works in ASP.NET Core, compare constructor injection and invoke async injection, and learn how transient, scoped, and singleton services behave within middleware.
Discover multiple ways to register a service in .NET 5, including singleton and transient options in startup.cs, using concrete implementation, abstraction, or type of with the implementation.
Register services in the dependency injection container and prevent overwriting existing implementations using try add transient. This keeps the v2 market forecaster when a new version is added, boosting stability.
Registering the same service multiple times adds multiple implementations to the container as transient, not replacing them. By default, the container resolves the last registered implementation.
Learn how to replace and remove registrations in .NET 5 dependency injection, swapping v2 with market forecaster and removing all implementations of IMarketForecaster.
Build a small ASP.NET core app to submit a credit application, implementing validations and dependency injection, and create a database with a credit application model via migrations.
Create the credit result view model and two views for credit application and credit result, wire up the controller actions and model binding in ASP.NET Core.
Implement multiple validation checkers in .NET 5 by creating the IValidation checker interface and two implementations: address and credit validators, and register them to validate credit applications.
Demonstrates building a credit validator interface that aggregates multiple validation checkers via dependency injection in .NET 5, returning a boolean result and a list of validation errors.
Register the credit validator and its validation checkers in startup.cs using services.AddScoped, wiring ICreditValidator and IValidationChecker implementations for dependency injection.
Test and debug a .NET 5 dependency injection scenario, fix a binding issue, validate salary, date of birth, age/credit rules, and postal code, then process an approved credit application.
Apply dependency injection to the application DbContext, add a credit model via Entity Framework, and save changes to create a new record in the sequel server database.
Register multiple validation checkers without duplicates using TryAddEnumerable in startup, ensuring both address and credit validators are resolved through the dependency injection container.
Configure conditional dependency injection in .NET 5 by using a scoped factory to select ICreditApproved implementations (high or low) based on a credit approval enum, applying 30% or 50% rules.
Inject a conditional credit service in a .NET 5 controller action to select high or low credit approvals by salary, then compute and display the result.
Inject and configure ILogger in the home controller, log actions to the debug window by default, and enable file logging with serilog.extensions.logging.file via loggerFactory.AddFile.
Consolidate service registrations by adding a new configure DI services file and an AddAllServices extension to streamline startup configuration and keep the DI setup clean.
Discover implementing a clean repository pattern with dependency injection in a .NET 5 project, including unit of work and a credit application repository backed by entity framework core.
Implement the repository pattern with a unit of work in a .NET 5 app, register IUnitOfWork in startup, inject into the home controller, and save changes to the database.
Continue your dependency injection study in .NET 5 (.NET Core) with additional ASP.NET Core courses on bhrugen.com, enjoying promotions and the lowest prices on udemy.
Dependency Injection is one of those terms that are used very often and are not understood most of the time.
This course will teach you everything you need to know about using dependency injection in ASP.NET Core. The skills you will learn will help you to build and architect complex ASP.NET Core applications that make full use of dependency injection. We will start with the basics of Dependency Injection and then we would dive into advanced concepts.
In old times we had to use third-party libraries for dependency injection but with .NET Core , dependency injection has been an integrated part of the .NET and it has great capabilities!
We will learn about all the topics that are needed to master Dependency Injection. By the end of the course, you will be fluent with all questions when it comes to dependency injection.
Discover why Dependency Injection is essential for modern .NET development and how it solves real-world problems like tight coupling and difficult testing. You'll start with the core concepts, understanding the Dependency Inversion Principle and how DI fits into SOLID principles.
Master the built-in .NET Dependency Injection container, learning how to register services with different lifetimes (Transient, Scoped, and Singleton) and understand when to use each. You'll explore constructor injection, property injection, and method injection patterns, knowing exactly when each approach is appropriate.
Move beyond the basics with advanced scenarios including working with multiple implementations, using factory patterns, handling complex object graphs, and implementing decorators. You'll learn how to configure third-party DI containers like Autofac when you need more advanced features.
Apply DI in real-world contexts across ASP.NET Core applications, including MVC, Web APIs, and Blazor. You'll see how to inject dependencies into controllers, services, middleware, and background services, while following architectural patterns like Repository and Unit of Work.