Creating many-to-many maps
A many-to-many relation is another of those "canonical" ones. Essentially, each entity on one of the sides can be associated with many entities on the other side, and this goes the other way too. Just think of these use cases:
- A post and its tags, where a tag can have multiple posts and a post multiple tags
- Books and authors
- Projects and developers
Usually, a many-to-many relation is easy to represent in classes: each side holds a collection of entities of the other side. In Entity Framework Core, however, things are not so simple. I'm sorry to break this to you, but as it happens, many-to-many relations are not supported! Do not be alarmed, though, there's still something we can do about it! This was a change from previous versions (Entity Framework 6.x) and one that will certainly be fixed. In the meantime, let's get it working.
Note
In Entity Framework Core, many-to-many relations are simulated with a middle entity. This even allows you to...