public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var provider = scope.ServiceProvider; provider.GetService <ApplicationDbContext>().Database.Migrate(); ApplicationRole.CreateRoles(provider, Startup.Configuration); // This is used on the first build. } host.Run(); }