Hello,
I have just extended my IdentityRole following this tutorial: http://johnatten.com/2014/06/22/asp-net-identity-2-0-customizing-users-and-roles/
public class ApplicationRole : IdentityRole { public ApplicationRole() : base() { } public ApplicationRole(string name) : base(name) { } public String ApplicationId { get; set; } public AspNetApplications Application { get; set; } }
I have also updated my RoleManager in my IdentityConfig file like this:
public class ApplicationRoleManager : RoleManager<ApplicationRole> { public ApplicationRoleManager( IRoleStore<ApplicationRole, string> roleStore) : base(roleStore) { } public static ApplicationRoleManager Create( IdentityFactoryOptions<ApplicationRoleManager> options, IOwinContext context) { return new ApplicationRoleManager( new RoleStore<ApplicationRole>(context.Get<ApplicationDbContext>())); } }
However, the issue starts when I try to Seed my data, I get this error: IdentityRole is not part of the model for the current context
Also, when I try to login to my application, it shows that this line is giving out the error:
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
I'm quite confused as to what I need to do properly to add one column to my AspNetRoles table and actually get data from it. E.g.
List<ApplicationRole> data = (from ar in dbContext.Roles join a in dbContext.AspNetApplications on ar.ApplicationId equals a.Id select new ApplicationRole { Id = ar.Id, ApplicationId = ar.ApplicationId, Name = ar.Name }).ToList();
I'm using ASP.NET MVC5. Hope someone can help with this. I've tried this for several days now.