This commit is contained in:
2026-06-18 21:07:28 -04:00
parent eefbb62eb7
commit 50dcc8e55c
29 changed files with 502 additions and 179 deletions
+5 -14
View File
@@ -11,10 +11,7 @@ builder.Services.AddRazorPages();
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<AppDbContext>(options =>
{
if (!string.IsNullOrEmpty(connectionString))
{
options.UseNpgsql(connectionString);
}
if (!string.IsNullOrEmpty(connectionString)) options.UseNpgsql(connectionString);
});
var app = builder.Build();
@@ -25,26 +22,20 @@ using (var scope = app.Services.CreateScope())
try
{
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
if (!string.IsNullOrEmpty(connectionString))
{
db.Database.Migrate();
}
if (!string.IsNullOrEmpty(connectionString)) db.Database.Migrate();
}
catch (Exception ex)
{
Console.WriteLine($"[WARNING] Database migration failed: {ex.Message}. The application will continue without a database connection.");
Console.WriteLine(
$"[WARNING] Database migration failed: {ex.Message}. The application will continue without a database connection.");
}
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error");
}
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
@@ -55,4 +46,4 @@ app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");
app.Run();
app.Run();