← Back
Milan Jovanovic January 18, 2025 32s

What they don't tell you about Scoped Services in .NET

Summary

When resolving services in .NET outside a global scope, you need to manually create a local service scope using the `ServiceScopeFactory`. This allows you to instantiate and resolve services, such as an EF Core database context, within a short-lived context. The takeaway is that proper scope management ensures services are disposed of when that context concludes.

View original episode ↗