The Right Way To Use Scoped Services From Singletons in ASP.NET Core
Get the source code for this video for FREE → https://the-dotnet-weekly.ck.page/sco... ☄️ Master the Modular Monolith Architecture: https://bit.ly/3SXlzSt 📌 Accelerate your Clean Architecture skills: https://bit.ly/3PupkOJ 🚀 Support me on Patreon to access the source code: / milanjovanovic Did you ever need to inject a scoped service into a singleton service? I often need to resolve a scoped service, like the EF Core DbContext, in a background service. Another example is when you need to resolve a scoped service in ASP.NET Core middleware. If you ever tried this, you were probably greeted with an exception. In this video, I'll explain how you can solve this problem and safely use scoped services from within singletons in ASP.NET Core. Check out my courses: https://bit.ly/3PupkOJ Using Scoped Services From Singletons in ASP.NET Core https://www.milanjovanovic.tech/blog/... Join my weekly .NET newsletter: https://www.milanjovanovic.tech Read my Blog here: https://www.milanjovanovic.tech/blog Chapters 0:00 Injecting Scoped services in Background jobs 3:07 Resolving Scoped services with IServiceScopeFactory 4:55 IServiceProvider vs IServiceScopeFactory 6:08 Injecting Scoped services in Middleware

Structuring Dependency Injection In ASP.NET Core The Right Way

The Best Way to Implement Long Running Tasks in .NET - Hangfire, Blazor, SignalR

IServiceProvider in ASP.NET Core: Dependency Injection Simplified with Real-Life Examples

Middleware Pattern For HttpClient With Delegating Handlers

Clean Architecture with ASP.NET Core 10

What Nobody Tells You About Being a Quant

Cancellation Tokens with Stephen Toub

Background Tasks Are Finally Fixed in .NET 8

The Right Way to Scale Long-Running API Requests

Every Frontend Architecture Pattern Explained in 23 Minutes

NGINX Explained - What is Nginx

What World Class Software Engineers Do That You Don't

Getting Started with Modular Monoliths in .NET

Background Jobs in ASP.NET Core

GitHub Copilot Update: It Didn't Age Well

Design a File Upload Service Like a Senior Engineer

Should my Services be Transient, Scoped, or Singleton?

Learn Dependency Injection in less than 20 minutes! - C# DI - #csharp #dependencyinjection #net

Turing Award Winner: Disagreeing with Google, Postgres, Future Problems | Mike Stonebraker

