39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Microsoft.AspNetCore;
|
|||
|
using Microsoft.AspNetCore.Hosting;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
using Microsoft.Extensions.Logging;
|
|||
|
using ThAmCo.Venues.Data;
|
|||
|
|
|||
|
namespace ThAmCo.Venues
|
|||
|
{
|
|||
|
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<IHostingEnvironment>();
|
|||
|
var context = services.GetRequiredService<VenuesDbContext>();
|
|||
|
if (env.IsDevelopment())
|
|||
|
{
|
|||
|
context.Database.EnsureDeleted();
|
|||
|
}
|
|||
|
context.Database.Migrate();
|
|||
|
}
|
|||
|
|
|||
|
host.Run();
|
|||
|
}
|
|||
|
|
|||
|
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
|||
|
WebHost.CreateDefaultBuilder(args)
|
|||
|
.UseStartup<Startup>();
|
|||
|
}
|
|||
|
}
|