diff --git a/src/Marathon.Hosts.WpfBlazor/App.xaml.cs b/src/Marathon.Hosts.WpfBlazor/App.xaml.cs index ea8e92e..336f257 100644 --- a/src/Marathon.Hosts.WpfBlazor/App.xaml.cs +++ b/src/Marathon.Hosts.WpfBlazor/App.xaml.cs @@ -83,6 +83,17 @@ public partial class App : System.Windows.Application builder.Services.AddSingleton(); 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(); + initializer.InitializeAsync().GetAwaiter().GetResult(); + } + Host.Start(); // Apply default culture from configuration before any UI renders. diff --git a/src/Marathon.Infrastructure/Migrations/20260505000000_InitialCreate.cs b/src/Marathon.Infrastructure/Migrations/20260505000000_InitialCreate.cs index 53cfa6d..19cafbc 100644 --- a/src/Marathon.Infrastructure/Migrations/20260505000000_InitialCreate.cs +++ b/src/Marathon.Infrastructure/Migrations/20260505000000_InitialCreate.cs @@ -1,3 +1,5 @@ +using Marathon.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -5,6 +7,8 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Marathon.Infrastructure.Migrations; /// +[DbContext(typeof(MarathonDbContext))] +[Migration("20260505000000_InitialCreate")] public partial class InitialCreate : Migration { /// diff --git a/src/Marathon.UI/wwwroot/index.html b/src/Marathon.UI/wwwroot/index.html index e24adff..fd229df 100644 --- a/src/Marathon.UI/wwwroot/index.html +++ b/src/Marathon.UI/wwwroot/index.html @@ -38,6 +38,9 @@ × + + +