DbContext never null

This commit is contained in:
2025-07-02 22:17:51 +02:00
parent e327e93163
commit 4dcd6ee035

View File

@ -5,7 +5,7 @@ namespace API.Workers;
public abstract class BaseWorkerWithContext<T>(IEnumerable<BaseWorker>? dependsOn = null) : BaseWorker(dependsOn) where T : DbContext
{
protected T? DbContext = null;
protected T DbContext = null!;
public void SetScope(IServiceScope scope) => DbContext = scope.ServiceProvider.GetRequiredService<T>();
/// <exception cref="ConfigurationErrorsException">Scope has not been set. <see cref="SetScope"/></exception>