Reputation: 13895
I am trying to add a property to the AspNetRoles table in ASP.NET Core Identity. I assumed the process would be the following:
Create an ApplicationRole class that implements IdentityRole just like ApplicationUser implements IdentityUser.
Add new property to ApplicationRole class.
Replace IdentityRole with ApplicationRole throughout the application where necessary.
i.e.
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
During step 4 when adding the migration I end up with an empty migration file. Any idea why this isn't working like it works when adding additional properties to ApplicationUser and then adding migration?
I noticed ApplicationDbContext implements IdentityDbContext. How can I add my ApplicationRole to this. I believe this is my problem.
Upvotes: 0
Views: 365
Reputation: 2867
I don't know how is your ApplicationDbContext, but I think you have to put something like this in the declaration of it:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, string>
Upvotes: 1