public static void Main(string[] args) { SetLogger(args); IHost host = CreateHostBuilder(args).Build(); try { Log.Information("Starting"); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { PgsqlDbContext.EnsureCreated(services); } catch (Exception ex) { Log.Fatal(ex, "An error occurred seeding the DB."); } } } catch (Exception ex) { Log.Fatal(ex, "Fatal Error"); } host.Run(); }
public BooksController(PgsqlDbContext context) { _context = context; }