Exemplo n.º 1
0
        private static void SeedInitialData(IApplicationBuilder app)
        {
            using (var scope = app.ApplicationServices.CreateScope())
            {
                #region seed identity data

                var identityContext = scope.ServiceProvider.GetService <ApplicationContext>();
                var identitySeed    = new SeedDummyData(identityContext);
                var roleManager     = scope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole <Guid> > >();

                if (!roleManager.Roles.Any())
                {
                    identitySeed.CreateRolesAsync(scope.ServiceProvider).GetAwaiter().GetResult();
                }
                identitySeed.CreateUsersAsync(scope.ServiceProvider).GetAwaiter().GetResult();


                #endregion
            }
        }
Exemplo n.º 2
0
        private static void SeedInitialData(IApplicationBuilder app)
        {
            using (var scope = app.ApplicationServices.CreateScope())
            {
                #region seed identity data

                var identityContext = scope.ServiceProvider.GetService <ApplicationDbContext>();
                var identitySeed    = new SeedDummyData(identityContext);

                if (!identityContext.Roles.Any())
                {
                    identitySeed.CreateRolesAsync(scope.ServiceProvider).GetAwaiter().GetResult();
                }
                identitySeed.CreateUsersAsync(scope.ServiceProvider).GetAwaiter().GetResult();
                identitySeed.CreateDistrictsAsync(scope.ServiceProvider).GetAwaiter().GetResult();


                #endregion
            }
        }