c# – How to use various classes as User in Identity – Asp.Net Identity

Question:

I want to use 2 classes as User in Identity and I couldn't see this change in the code.

Let's say I'm going to use the default class "ApplicationUser" which generates an "AspNetUsers" table and I want to use another "Customers" table that inherits from Identity.

The ApplicationUser class already inherits from Identity and works fine. I saw that there is an ApplicationUserManager class and others that inherit from ApplicationUser. Example:

public class ApplicationUser : IdentityUser

public class ApplicationUserManager : UserManager<ApplicationUser>

public class ApplicationSignInManager : SignInManager<ApplicationUser, string>


public class Cliente: IdentityUser

My question is whether I will need to create new classes to inherit from Client, for example:

public class ApplicationUserManagerCliente : UserManager<Cliente>
public class ApplicationSignInManagerCliente : SignInManager<Cliente, string>

Is it that or am I thinking wrong?

Answer:

As I understand it, you want to create two types of users the Conventional User (UserEntity) and the System Administrator (AdminUserEntity). The UserEntity will access the normal site and the Administrator will access another site (adm).

I believe that the ideal would be, create a single user with the standard characteristics between the 2 and give them specialized Claims, eg Profile = Admin, AcessoSites = OutrosSite.

See if this link here can help you: https://stackoverflow.com/questions/22855428/how-to-change-table-names-for-asp-net-identity-2-0-with-int-id-columns

there is a tutorial that can help you: http://eduardopires.net.br/2014/08/asp-net-identity-tutorial-completo/

Scroll to Top