How do you configure a Many-to-Many relationship in EF Core?

Updated Apr 28, 2026

Short answer

In EF Core 5+, many-to-many relationships are supported implicitly just by adding collection navigation properties to both entities.

Deep explanation

EF Core automatically creates a hidden join table. If you need payload (extra columns) in the join table, you must explicitly create the join entity and configure it as two one-to-many relationships using the HasMany().WithMany().UsingEntity() Fluent API.

Real-world example

Modeling Students and Courses where a student can enroll in multiple courses, and a course has multiple students.

Common mistakes

  • Trying to use implicit many-to-many in EF Core 3.1 or older, which required an explicit join entity.

Follow-up questions

  • How do you access the hidden join table in LINQ queries?

More Entity Framework interview questions

View all →