Apporach # 1:
A claim approach can be a way. This way you get from IdentityUser usual way and add common properties to the derived class. Then, for each type of user, you add additional claims using UserManager.AddClaimAsync .
So, for example, let's say you create a class class of the new AppUser class. Then you can:
AppUser teacher = new AppUser { }; await userManager.AddClaimAsync(teacher.Id, new Claim("app_usertype", "teacher")); await userManager.AddClaimAsync(teacher.Id, new Claim("app_grade", 4)); await userManager.AddClaimAsync(teacher.Id, new Claim("app_exp", 10)); await userManager.AddClaimAsync(teacher.Id, new Claim("app_awards", "Award1,Award2")); await userManager.AddClaimAsync(teacher.Id, new Claim("app_langspoken", "English,French,German")); AppUser student = new AppUser { }; await userManager.AddClaimAsync(student.Id, new Claim("app_usertype", "student")); await userManager.AddClaimAsync(student.Id, new Claim("app_grade", 2));
They will add different requirements to different types of users. Thus, the teacher claims to have "app_experience" of "10", "app_awards" of "Award1" and "Award2", etc. On the other hand, student claims to have only "app_grade" from "2".
Basically, the first parameter determines the type of claim, and the second parameter determines the data that supports this claim. The type can be any, so choose what makes sense for your application, and perhaps the prefix of each name to distinguish it from others. In the case where I only prefix "application".
Then you can use UserManager.GetClaimsAsync to receive all claims against the user and search the returned list of the application you are interested in.
Approach # 2
Another approach would be to create an AppUser class, followed by teacher and student , which is derived from AppUser . In these classes, you would add properties that would otherwise be added as claims in the example above.
The slight drawback to this is that you will have to create separate tables for each of these different users, and the relationship back to the ASP.NET user identifier table.
Also using FindByUserNameAsync , FindByEmailAsync etc. will only return one type of TUser , in this case AppUser . In addition, these methods will query only one table, AspNetUsers , so you will need to extract additional information from the corresponding teacher or student table.