public static IServiceCollection UseEntityFramework(this IServiceCollection services) { services.TryAddSingleton(provider => { var configuration = provider.GetRequiredService <IConfiguration>(); return(EntityFrameworkOptionsCollection.LoadFrom(configuration)); }); services.TryAddSingleton <IEntityConfigurationTypeFinder>(provider => { var finder = new EntityConfigurationTypeFinder(provider .GetRequiredService <ILogger <EntityConfigurationTypeFinder> >()); ((IEntityConfigurationTypeFinder)finder).Initialize(); return(finder); }); services.TryAddScoped <DbContextFactory>(); services.AddInitializer <EntityFrameworkInitializer>(); return(services); }