Error: Application startup exception: System.InvalidOperationException: Cannot resolve scoped service from root provider.
Solution: There is a chance that you are trying to inject a Service into an Asp.Net Core 3.1 Middleware through a constructor. Instead of injecting a Service Interface through a Middleware Constructor, inject it through an invoke method/function like so:
public async Task Invoke(HttpContext context, IAnalytics analytics)
{
//Then use your Service in here
analytics.SomeFunction();
}