Example #1
0
        private static void SeedDatabase(ApplicationInitializationContext context)
        {
            using (var scope = context.ServiceProvider.CreateScope())
            {
                AsyncHelper.RunSync(async() =>
                {
                    var identitySeedResult = await scope.ServiceProvider
                                             .GetRequiredService <IIdentityDataSeeder>()
                                             .SeedAsync(
                        "1q2w3E*"
                        );

                    if (identitySeedResult.CreatedAdminRole)
                    {
                        await scope.ServiceProvider
                        .GetRequiredService <IPermissionDataSeeder>()
                        .SeedAsync(
                            RolePermissionValueProvider.ProviderName,
                            "admin",
                            IdentityPermissions.GetAll().Union(MyProjectNamePermissions.GetAll())
                            );
                    }
                });
            }
        }
Example #2
0
 private static void SeedDatabase(ApplicationInitializationContext context)
 {
     AsyncHelper.RunSync(async() =>
     {
         await context.ServiceProvider
         .GetRequiredService <IIdentityDataSeeder>()
         .SeedAsync(
             "1q2w3E*",
             IdentityPermissions.GetAll()
             .Union(MyProjectNamePermissions.GetAll())
             );
     });
 }