I have two models which both have a collection of the same third model. Ef Core 5 now creates a foreign key for both models on the collection model but is there a way to let it generate a join table for each relationship without explicitly having a model for the join table?
My Models:
public class Model1 {
// ...
public List<Model3> collection;
}
public class Model2 {
// ...
public List<Model3> collection;
}
public class Model3 {
// ...
}
I want the db to look something like this:
Table: Model1
Table: Model2
Table: Model3
Table: Model3Model1 (JoinTable)
- Model3Id
- Model1Id
Table: Model3Model2 (JoinTable)
- Model3Id
- Model2Id
But I don't want explicit Types for those join tables. I know that EFCore is able to infer those join tables for many-to-many relationship so I was wondering if there is a way to do this for one-to-many as well.