Base solution for your next web application
Open Closed

Custom UserTypes #5626


User avatar
0
sbenfares created

Hi,

I need to handle 2 (or more) types of Users in my application (Example Teacher & Students) Each user wil have common properties (defined in User Table) and have specific fields.

What is the best approach for integrate this with ANZ ?

PS : In my previous application i used Asp.net Identity 2.0 table AspNetUser and Created 2 specific tables : Student & Teacher. On AspNetUser i created a nullable Foreign Key to Student and Teacher table. I followed this recommandation : https://stackoverflow.com/questions/27059017/creating-inheritance-users-from-base-asp-net-identity-user

Then to retrieve Student data i used User.Student.Name

Is that a good practice for you ? Should i use the same method for ANZ and AbpUsers Table ? How can i add StudentId and TeacherId in AbpSession in ANZ ?

Thanks !


2 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    I think Students and Teachers should be 2 different roles. So that you can grant different permissions to them. And you'll have only 1 UserId in AbpSession. Other method is extending User entity. See how to extend existing entities.

  • User Avatar
    0
    ukocabicak created

    I think TPH approach is very subtle for your case.

    You can extend User to an abstract Person entity. Than extending Person to seperate Student and Teacher entities which will be resulting your table holding both Student and Teacher users with a discriminator.