2

I'm trying to have two different UserManagers.

app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);

app.CreatePerOwinContext<CustomUserManager>(CustomUserManager.Create);
app.CreatePerOwinContext<CustomRoleManager>(CustomRoleManager.Create);

Both ApplicationUser and CustomUser inherit IdentityUser.

How do I configure OnModelCreating to support the Roles/Claims/Logins correctly?

Am I doing something that would be considered bad practice? I just want to completely separate these two types of users. I don't want TPH since I need different required properties.

UPDATE

To further explain why I think I need this, is because I would like to have different roles and properties for these two types of users. If they share the same table, I would need a optional one-to-one relation to add properties, allow same UserNames, and who knows what else.

Dominique Alexandre
  • 1,023
  • 10
  • 29

1 Answers1

2

I made two custom UserManagers (e.g., CustomUserManager : UserManager<CustomUser>) where CustomUser inherits from IdentityUser and is specified as Table per Type with [Table("CustomUser")] on the class.

The context needs to be IdentityDbContext, or DbContext with the same DbModelBuilder settings.

Same thing goes for the roles if needed (e.g., CustomRoleManager : RoleManager<CustomRole>), they will be Table per Hierarchy. Though there isn't much use to this unless you modify the Authorize attribute and add the Claim to match the Discriminator and the role's Name.

Dominique Alexandre
  • 1,023
  • 10
  • 29