public static void Main(string[] args) { var webHost = BuildWebHost(args); using (var scope = webHost.Services.CreateScope()) { var services = scope.ServiceProvider; try { var db = services.GetRequiredService <TMDbContext>(); var idsDb = services.GetRequiredService <PersistedGrantDbContext>(); db.Database.Migrate(); idsDb.Database.Migrate(); AppConfigurator.InitRolesAndUsers(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while migrating and initialization of the database."); } } webHost.Run(); }