Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            //BuildWebHost(args).Run();
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context     = services.GetRequiredService <ApplicationDbContext>();
                    var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >();

                    ApplicationDbInitializer.InitializeIdentity(context, roleManager).Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "Error occured while seeding database");
                }
            }

            host.Run();
        }