I've got this code to define my ApplicaitonUser. Name and Created are custom fields I have added.
How do I do the same thing for the Roles? I need to add an integer field to them.
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;
}
}
You can add a custom field to the Roles table by deriving from IdentityRole class.
Code snippet: