...
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user