Cannot convert lambda expression to type 'ServiceLifetime' because it is not a delegate type on Asp.net core 2.2

I had the same error in my project. The problem was that my context class was not derived from DbContext.

public class SecurityContext : DbContext
{
}

SecurityContext is not a DbContext. If you have a DbContext called SecurityContext in your project, remove using System.Security; from your usings in your Startups.csclass or rename the DbContext to something like SecurityDbContext.

The generic type you are using when calling AddDbContext is from the System.Security namespace, but it should be your Database context.