public static async Task InitializeAsync(IWebHost host) { using (var scope = host.Services.CreateScope()) using (var context = scope.ServiceProvider.GetService <CelebrityDataContext>()) { if (context.HasMigrations()) { await context.Database.MigrateAsync().ConfigureAwait(true); await CelebrityDataContext.CreateSeedDataAsync(context).ConfigureAwait(true); } } }
public static void Initialize(IWebHost host) { CelebrityDataContext.InitializeAsync(host).GetAwaiter().GetResult(); }