https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/whatsnew#many-to-many
EF Core 5 has refined the many to many relationship, we don't need to define a Entity for the "relation table", EF Core 5 will internally automatically generated the table.
Then, how can I define the DbSet for referencing to do CRUD?
e.g.
class T1
{
public string id1{get;set;}
public virtual ICollection<T2> T2{get;set;}
}
class T2
{
public string id2{get;set;}
public virtual ICollection<T1> T1{get;set;}
}
public DbSet<T1> t1{ get; set; }
public DbSet<T2> t2{ get; set; }
Note: T1, T2, T1T2 are automatically generated by EF Core in the SQLite.
T1T2 class I don't define it actually.
class T1T2 { public string id1{get;set;} public string id2{get;set;} }
So no
public DbSet<T1T2> t1t2{ get; set; }
While I what to add a record to T1T2, how to get the reference of the Table T1T2? Or do I have any other way to do so?