using ApplianceRepair; using ApplianceRepair.Components; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddDbContext(options => options.UseSqlite("Data Source=site.db")); builder.Services.AddMemoryCache(); builder.Services.AddLogging(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var services = scope.ServiceProvider; try { services.GetRequiredService().Database.EnsureCreated(); } catch (Exception ex) { var logger = services.GetRequiredService>(); logger.LogError(ex, "An error occurred creating the DB."); } } // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); } app.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();