public static void Main(string[] args) { var host = CreateHostBuilder(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var serviceProvider = services.GetRequiredService <IServiceProvider>(); SeedDb.CreateRoles(serviceProvider).Wait(); } catch (Exception e) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(e, "An error occurred while creating roles"); } } host.Run(); }