I want to create a Many to Many relationship with Student table and IdentityUser table that EF provides. I created a Teacher Entity and Injected "IdentityUser". Below are the entities now -
1. Student
2. Teacher : IdentityUser
3. StudentTeacher
Any guides on how to do it?
Amit MohantyPosted Mar 29, 2023, 4:03 AM
To create a many-to-many relationship between the Student and Teacher entities, you can use the StudentTeacher entity as a linking table. This table will have foreign keys to both the Student and Teacher entities.
For example:
To configure the many-to-many relationship in EF, you can use the HasMany and WithMany methods in the OnModelCreating method of your DbContext.
Jignesh KumarPosted Mar 29, 2023, 3:57 AM
hello Bell,
Please refer this one which will help you out,
https://www.entityframeworktutorial.net/efcore/configure-many-to-many-relationship-in-ef-core.aspx