Exemple #1
0
        public static IWebHost SeedData(this IWebHost host)
        {
            using (var scope = host.Services.CreateScope())
            {
                IServiceProvider           services    = scope.ServiceProvider;
                ShoppingDbContext          context     = services.GetService <ShoppingDbContext>();
                UserManager <UserEntity>   userManager = services.GetService <UserManager <UserEntity> >();
                RoleManager <IdentityRole> roleManager = services.GetService <RoleManager <IdentityRole> >();
                IConfiguration             config      = services.GetService <IConfiguration>();

                DatabaseSeeder.SeedRoles(roleManager);
                DatabaseSeeder.SeedUsers(userManager, config);
            }
            return(host);
        }