Home > Back-end >  Accessing third table auto generated by entity framework when using many-to-many in models
Accessing third table auto generated by entity framework when using many-to-many in models

Time:11-30

When a many-to-many relation is defined within models, a third table is auto created by Entity framework. I am able to see this table within the database but I am not sure how I would access it's data. The third table is ApplicationUserProject defining a relationship between Projects and Users

How might access this table and it's data? Thanks in advance

Third generated table

enter image description here

CodePudding user response:

In your particular case you do not need access to intermediate table.

var query = context.Users
  .Where(u => u.Projects.Any(p => p.Id == projectId));
  • Related