using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using ThAmCo.Products.Data; namespace ThAmCo.Products { public class Program { public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var env = services.GetRequiredService(); if (env.IsDevelopment()) { var context = services.GetRequiredService(); context.Database.EnsureDeleted(); context.Database.Migrate(); } } host.Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup(); } }