using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace OFBButte.Api { public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Run(); } public static IWebHost CreateWebHostBuilder(string[] args) { var hostBuilder = WebHost.CreateDefaultBuilder(args) .UseStartup(); if (args.Length >= 1) { hostBuilder.UseUrls($"http://localhost:{args[0]}"); } var host = hostBuilder.Build(); using(var scope = host.Services.CreateScope()) { var db = scope.ServiceProvider.GetService(); db.Database.Migrate(); } return host; } } }