diff --git a/src/TrueCV.Web/Program.cs b/src/TrueCV.Web/Program.cs index 7d183ec..9d1e006 100644 --- a/src/TrueCV.Web/Program.cs +++ b/src/TrueCV.Web/Program.cs @@ -1,6 +1,7 @@ using Hangfire; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; using Serilog; using TrueCV.Infrastructure; using TrueCV.Infrastructure.Data; @@ -70,7 +71,7 @@ try var app = builder.Build(); - // Seed default admin user + // Seed default admin user and clear company cache using (var scope = app.Services.CreateScope()) { var userManager = scope.ServiceProvider.GetRequiredService>(); @@ -88,6 +89,16 @@ try await userManager.CreateAsync(adminUser, defaultPassword); Log.Information("Created default admin user: {Email}", defaultEmail); } + + // Clear company cache on startup to ensure fresh API lookups + var dbContext = scope.ServiceProvider.GetRequiredService(); + var cacheCount = await dbContext.CompanyCache.CountAsync(); + if (cacheCount > 0) + { + dbContext.CompanyCache.RemoveRange(dbContext.CompanyCache); + await dbContext.SaveChangesAsync(); + Log.Information("Cleared {Count} entries from company cache", cacheCount); + } } // Configure the HTTP request pipeline.