Cómo usar servicios scoped dentro de un BackgroundService en ASP.NET Core 11
Un BackgroundService es un singleton, así que no puede inyectar directamente un servicio scoped como un DbContext. Toma IServiceScopeFactory, abre un scope por unidad de trabajo con CreateAsyncScope, resuelve dentro de él y deséchalo al terminar.