public static IHost MigrateDatabase <T>(this IHost host) where T : DbContext { using (IServiceScope scope = host.Services.CreateScope()) { IServiceProvider services = scope.ServiceProvider; var db = services.GetRequiredService <ProductContext>(); if (db.Database.GetPendingMigrations().Any()) { db.Database.Migrate(); } DbSeed.InitialProducts(db); } return(host); }