ARTICLE AD BOX
My ASP.NET Core app is throwing this exception, and I can't figure out how to resolve it:
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'HealthChecksDb' has pending changes. Add a new migration before updating the database.
My own code has no context HealthChecksDb, so it must be something internal to ASP.NET Core.
But what are the "pending changes"?
My code has no context HealthChecksDb, so it must be it must be something internal to ASP.NET Core I guess? I don't have any tables named HealthCheck I haven't made any schema changes. If I do dotnet ef add to create a migration, that migration is empty (and it should be)I'm completely stumped. I don't even know what to investigate here.
Here are my code excerpts:
// From Main: IHost host = CreateHostBuilder(args, log, appSettings, app).Build(); new Thread(() => { host.Run(); }) { IsBackground = true }.Start(); /// <------- SOURCE OF STACKTRACE // And now the function that the above code calls, // which is where the problem probably really is: public static IHostBuilder CreateHostBuilder(string[] args, ILogger log, MyAppSettings appSettings, MyApp myapp) { return Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { string port = Environment.GetEnvironmentVariable("MYPORT"); webBuilder.UseKestrel(); webBuilder.UseUrls($"http://*:{port}"); webBuilder.ConfigureServices((services) => { string configString = "Host=blah;Database=blah{1};Username=blah{2};Password=blah;Include Error Detail=True"; services.AddSingleton(myapp); /// If I comment out these two AddHealthCheck calls, /// the exception is not thrown (unsurprisingly). services.AddHealthChecks() .AddCheck("MyAppHealth", new HealthCheck(myapp)); services.AddHealthChecksUI() .AddPostgreSqlStorage(configString); services.AddControllers(); }); webBuilder.Configure(app => { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapHealthChecks($"/myapp_health"); endpoints.MapHealthChecks($"/myapp_health_ui", new HealthCheckOptions { ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); endpoints.MapControllers(); }); }); }) .UseSerilog(); }