using Microsoft.EntityFrameworkCore; using MudBlazor.Services; using timetracker.Components; using timetracker.Data; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddMudServices(); builder.Services.AddHttpClient(); var dbPath = Path.Combine(builder.Environment.ContentRootPath, "timetracker.db"); builder.Services.AddDbContextFactory(options => options.UseSqlite($"Data Source={dbPath}")); builder.Services.AddScoped(); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var factory = scope.ServiceProvider.GetRequiredService>(); await using var db = await factory.CreateDbContextAsync(); await db.Database.MigrateAsync(); } // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); app.UseHttpsRedirection(); app.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();