2017-02-09 2 views
1

У меня есть этот код для определения моего ApplicaitonUser. Имя и Создать - это настраиваемые поля, которые я добавил.Добавить пользовательское поле в роли MVC SimpleMembership

Как сделать то же самое для ролей? Мне нужно добавить к ним целое поле.

public class ApplicationUser : IdentityUser 
{ 
    public DateTime Created { get; set; } 
    public string Name { get; set; } 

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) 
    { 
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType 
     var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); 
     // Add custom user claims here 
     return userIdentity; 
    } 

    public ApplicationUser() 
    { 
     Created = DateTime.UtcNow; 
    } 
} 

ответ

1

Вы можете добавить настраиваемое поле в таблицу Роли, получив класс IdentityRole.

Фрагмент кода:

public class ApplicationRole : IdentityRole 
    { 
     public ApplicationRole() : base() 
     { 
     } 

     // New property 
     public int MasterRoleId{ get; set; } 
    } 
Смежные вопросы