Currently working on a project where a Website and a WPF app should get and update data to SQL server database through asp net core REST API, with use of EF Core.


Our problem is inserting records into the join table.
We have used the newly added autocreation of join tables (which came same time as .NET 5), with our many to many relations, which mean that we do not have a join table model class.
Example
Table: Person
Table: Hashtag
A person can follow many hashtags and a hashtag can be followed by many persons.
If we create a person in WPF and add some already existing hashtags to his collection. Then we serialize the person, and post it to the REST API, which will try to update the database through the entity framework.
The problem is that the EF will try to insert all the hashtags in the database, which it cannot because they already exists. This leads to the whole post failing, and us being unable to insert the person.
How do we make it just inserts the person and records to the join table?
We might have misunderstood something completely
This is not an issue. See this video. Around 14:45 mark to about 20:00 mark. https://youtu.be/BIImyq8qaD4
Basically you will have join table model as well and add mapping using fluent configuration.
So the only solution would be to ad join tabel model anyway ?
C# devs
null reference exceptions

source