/// <summary> /// Seeds the default data. /// </summary> private void Seed() { SaveChanges(); // Make sure we have a SysAdmin role var role = Roles.FirstOrDefault(r => r.Name == "SysAdmin"); if (role == null) { role = new Role { Id = Guid.NewGuid(), Name = "SysAdmin", NormalizedName = "SYSADMIN" }; Roles.Add(role); } // Make sure our SysAdmin role has all of the available claims //foreach (var claim in Piranha.Security.Permission.All()) foreach (var permission in App.Permissions.GetPermissions()) { var roleClaim = RoleClaims.FirstOrDefault(c => c.RoleId == role.Id && c.ClaimType == permission.Name && c.ClaimValue == permission.Name); if (roleClaim == null) { RoleClaims.Add(new IdentityRoleClaim <Guid> { RoleId = role.Id, ClaimType = permission.Name, ClaimValue = permission.Name }); } } SaveChanges(); }