This project is read-only.

Adding columns to AspNetRoles

May 21, 2014 at 10:42 PM
Can I add more columns into AspNetRoles table ? (Kinda database first approach) Will the framework pick new column automatically or do I have to change any auto-generated code ? When I added columns to AspNetUsers I had to modify class ApplicationUser : IdentityUser but I don't see any class generated for Roles.

What I'd like to do is have additional info where the role is used (eg. Area) so then I can group it in my view and maybe also detailed description of each role...

Thanks in advance
May 23, 2014 at 12:22 AM
You can add a new class ApplicationRole:IdentityRole and then use it in the RoleManager<ApplicationRole>. It should be persisted with any new properties added
May 23, 2014 at 11:10 PM
Edited May 23, 2014 at 11:11 PM
I forgot to mention that I'm using Identity 2. I think your answer applies to identity 1.0 - if I'm wrong can you please post a sample code extending Roles to additional property ?
May 30, 2014 at 5:54 PM
the solution should apply for either Identity 1.0 or 2.0

The sample code would be

public class AppRole:IdentityRole{
property string Description{get;set;}

var roleManager = new RoleManager<AppRole>(new RoleStore<AppRole>(new Context());

you can now use the 'roleManager' to manage your roles and it would use the 'AppRole' as the role class