Search code examples
asp.netentity-frameworkasp.net-coreasp.net-identity

How to manage multiple users with EF in ASP.NET Core


I am designing a database for a language learning center. I have 3 subjects to manage: admin, teacher and student.

  • Admin can assign the role to the other 2 objects
  • The teacher has the role of posting instructions on the website
  • Students can register for the course and pay

Should I create a teacher and a student table in the database? If so - how should I design them? Otherwise how should I manage just one user object?

I designed the AppUser class to inherit the identity user class, the student and teacher classes inherit from the AppUser class, is that a good approach?


Solution

  • A better solution is to create a teacher and a student table in the database. Because their roles are completely different, this can separate their respective businesses completely. Reduce the complexity of design.

    Create a login page, you can provide a drop-down list for users to choose their own roles, query the database according to the user's role, and then fill the user and the user's role to identity to achieve authentication.