public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .WriteTo.Console( outputTemplate: "[{Timestamp:HH:mm:ss} {level:u3}] {Message:lg} {Properties:j}{NewLine}{Exception}") .CreateLogger(); var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { Log.Information("Getting dcore application Up"); var context = services.GetRequiredService <DataContext>(); var usermanager = services.GetRequiredService <UserManager <AppUser> >(); Log.Information("Migrating the database from the migrations"); context.Database.Migrate(); SeedData.SeedActivities(context, usermanager).Wait(); host.Run(); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred during Migrations"); } finally { Log.CloseAndFlush(); } } }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <DataContext>(); var usermanager = services.GetRequiredService <UserManager <AppUser> >(); context.Database.Migrate(); SeedData.SeedActivities(context, usermanager).Wait(); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred during Migrations"); } } host.Run(); }