public static async Task Main(string[] args)
        {
            Log.Logger = SerilogExtension.CreateLogger();
            var host = CreateHostBuilder(args).Build();

            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;

            try
            {
                Log.Logger.Information("Application starting up...");
                var dbContext = services.GetRequiredService <HeroDbContext>();
                if (dbContext.Database.IsSqlServer())
                {
                    await dbContext.Database.MigrateAsync();
                }

                await host.RunAsync();
            }
            catch (Exception ex)
            {
                Log.Logger.Fatal(ex, "Application startup failed.");
                throw;
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
 public static void Main(string[] args)
 {
     Log.Logger = SerilogExtension.CreateLogger();
     try {
         Log.Logger.Information("Application starting up...");
         CreateHostBuilder(args).Build().Run();
     } catch (Exception ex) {
         Log.Logger.Fatal(ex, "Application startup failed.");
         throw;
     } finally {
         Log.CloseAndFlush();
     }
 }