fix(host): wire DB migration init + Plotly CDN + attribute fix on hand-written migration
Three fixes surfaced when launching the WPF host for the first time: 1. App.xaml.cs — call MarathonDbContextInitializer.InitializeAsync() between Host.Build() and Host.Start() so EF migrations + WAL pragma are applied BEFORE BackgroundServices race to query the DB. Without this, all pollers crashed on 'no such table: Events'. 2. wwwroot/index.html — added <script src='https://cdn.plot.ly/plotly-2.35.2.min.js'> before blazor.webview.js. Phase 6 reviewer flagged this for Phase 9, but charts are unrenderable without it; better to ship now. 3. Migrations/20260505000000_InitialCreate.cs — added [DbContext] and [Migration('20260505000000_InitialCreate')] attributes. Phase 2's hand-written migration was missing both, so EF saw 'no migrations to apply' even on a fresh DB. With the attributes, the migration runs on first launch and creates all tables (Events, Snapshots, Bets, EventResults, Anomalies, Sports, Leagues). Verified: clean DB → migration applied → all 7 tables created → pollers run with empty results (no data yet — UpcomingEventsPoller fires every 6h by default; first scrape will populate the DB).
This commit is contained in:
@@ -83,6 +83,17 @@ public partial class App : System.Windows.Application
|
||||
builder.Services.AddSingleton<MainWindow>();
|
||||
|
||||
Host = builder.Build();
|
||||
|
||||
// Apply EF migrations + WAL pragma BEFORE Host.Start() so the BackgroundServices
|
||||
// (LiveOddsPoller, AnomalyDetectionPoller, etc.) don't race the DB schema creation.
|
||||
// Resolved in a scope because MarathonDbContextInitializer is Scoped (DbContext lifetime).
|
||||
using (var initScope = Host.Services.CreateScope())
|
||||
{
|
||||
var initializer = initScope.ServiceProvider
|
||||
.GetRequiredService<Marathon.Infrastructure.Persistence.MarathonDbContextInitializer>();
|
||||
initializer.InitializeAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
Host.Start();
|
||||
|
||||
// Apply default culture from configuration before any UI renders.
|
||||
|
||||
Reference in New Issue
Block a user