public static IWebHost SeedingData(this IWebHost webHost) { using (var serviceScope = webHost.Services.CreateScope()) { var context = serviceScope.ServiceProvider.GetService <DataContext>(); var hostingEnvironment = serviceScope.ServiceProvider.GetService <IWebHostEnvironment>(); if (hostingEnvironment.EnvironmentName == "Development") { if (!context.News.Any()) { DataSeeder.InitNews(context); } } } return(webHost); }