using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using MedHelp.Data; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace MedHelp { public class Program { public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { SeedData.Initialize(services); } catch (Exception e) { var logger = services.GetRequiredService>(); logger.LogError(e, "An error occurred when trying to seed DB"); } } host.Run(); } public static IWebHost BuildWebHost(string[] args) { return WebHost.CreateDefaultBuilder(args) .UseStartup() #if DEBUG .UseUrls("http://localhost:5000/") #endif .Build(); } } }