public static async Task Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService <DatabaseContext>(); var migrations = await context.Database.GetPendingMigrationsAsync(); if (migrations.Count() > 0) { Console.WriteLine("Starting to migrate database...."); try { await context.Database.MigrateAsync(); Console.WriteLine("Database is up to date, #party time"); } catch (DbException) { Notify("Database Migration FAILED"); throw; } } } var task = host.RunAsync(); Notify("🚀"); WebHostExtensions.WaitForShutdown(host); }
public static async Task Main(string[] args) { var host = Utilities.CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService <DatabaseContext>(); var canContinue = await Utilities.WaitForMigrations(host, context); if (!canContinue) { return; } } var task = host.RunAsync(); Utilities.Notify("TamagotchiAPI Running!"); WebHostExtensions.WaitForShutdown(host); }
public static async Task Main(string[] args) { var host = Utilities.CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService <DatabaseContext>(); var canContinue = await Utilities.WaitForMigrations(host, context); if (!canContinue) { return; } } var task = host.RunAsync(); Utilities.Notify("HiddenMickey Running!"); Console.WriteLine("You must also have the ClientApp running. In a separate terminal, run:"); Console.WriteLine(" cd ClientApp"); Console.WriteLine(" npm start"); WebHostExtensions.WaitForShutdown(host); }