feat: Log EF Core migration errors instead of crashing the application at startup across all services.
This commit is contained in:
@@ -130,10 +130,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsAnalyticsServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsAnalyticsServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -130,10 +130,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsBillingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsBillingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -130,10 +130,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsManagerServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsManagerServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -135,10 +135,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsServingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsServingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -130,10 +130,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsTrackingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<AdsTrackingServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -149,10 +149,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<BookingContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<BookingContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -149,10 +149,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<CatalogContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<CatalogContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -205,10 +205,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<ChatServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<ChatServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -149,10 +149,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<FnbContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<FnbContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -152,10 +152,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<InventoryContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<InventoryContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -200,10 +200,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MembershipServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MembershipServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -153,10 +153,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MerchantServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MerchantServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -220,10 +220,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MiningServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MiningServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -150,10 +150,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MissionDbContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MissionDbContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -212,10 +212,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<OrderContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<OrderContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -194,10 +194,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<PromotionServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<PromotionServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -156,10 +156,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<SocialServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<SocialServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -185,10 +185,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<StorageServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<StorageServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -179,10 +179,19 @@ try
|
||||
// EN: Run the application / VI: Chạy ứng dụng
|
||||
// EN: Auto-apply EF Core migrations on startup
|
||||
// VI: Tự động áp dụng EF Core migrations khi khởi động
|
||||
using (var scope = app.Services.CreateScope())
|
||||
try
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<WalletServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<WalletServiceContext>();
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// EN: Log migration errors but don't crash the app (e.g. PendingModelChangesWarning in EF Core 10)
|
||||
// VI: Log lỗi migration nhưng không crash app
|
||||
Console.WriteLine($"Warning: EF Core migration issue: {ex.Message}");
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user