Member-only story

Many-To-Many Relationship with Entity Framework Core 3.0

Jorge Freitas
2 min readOct 24, 2020

--

This tutorial aims to be simple and quick because I notice some difficulty/doubts on the internet about the many-to-many relationship, nothing better than a simple example.

A many-to-many relationship between two entities represents a one-to-many from both sides, i.e. Contact and Skill entities.

  • A contact can have one or more skills
  • A skill can be present in one or more contacts

This is a simple and very fundamental question to Entity Framework Core many-to-many relationships.

Hands on!

You can find the full solution in my repository.

Scenario

A contact can have one or more skills and skill can belong to one or more contacts. In addition, I would like to know the expertise level that each contact has in each skill.

So for this scenario, we need three entities, Contact, Skill, and ContactSkill.

I modeled the domain as follows:

--

--

No responses yet