Created
January 28, 2019 12:54
-
-
Save evgomes/5efb75bbe67491a868f434ea4ef041e7 to your computer and use it in GitHub Desktop.
Program.cs from Supermarket API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using Supermarket.API.Persistence.Contexts; | |
namespace Supermarket.API | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var host = BuildWebHost(args); | |
using(var scope = host.Services.CreateScope()) | |
using(var context = scope.ServiceProvider.GetService<AppDbContext>()) | |
{ | |
context.Database.EnsureCreated(); | |
} | |
host.Run(); | |
} | |
public static IWebHost BuildWebHost(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>() | |
.Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment