There's a different approach that worked:
IServiceScope currentScope = HttpContext.Current.GetScope(); IServiceProvider serviceProvider = scope.ServiceProvider;
More details here.