public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetService <BookContext>(); var solr = services.GetService <ISolrService>(); var userService = services.GetService <IUserService>(); SampleDataService.AddSampleData(context, solr, userService); } host.Run(); }