.NET & C# ยท ASP.NET Core
How would you solve an interview scenario involving dependency injection lifetimes?
A BackgroundService is singleton but needs a DbContext. Inject IServiceScopeFactory, create a scope for each unit of work, and resolve the scoped DbContext from that scope.