As a result of trial and error, I found the following. Given two classes ...
public class AClass { public int Id { get; set; } public ICollection<BClass> BClasses { get; set; } } public class BClass { public int Id { get; set; } public ICollection<AClass> AClasses { get; set; } }
... and there is no Fluent mapping and DbContext like this ...
public class MyContext : DbContext { public DbSet<AClass> AClasses { get; set; } public DbSet<BClass> BClasses { get; set; } }
... name of the created BClasslasses connection table . If I change the order of the sets ...
public class MyContext : DbContext { public DbSet<BClass> BClasses { get; set; } public DbSet<AClass> AClasses { get; set; } }
... the name of the created join table changes to AClassBClasses , and the order of the key columns in the table also changes. Thus, the name of the join table and the order of the key columns, apparently, depend on the order in which the object classes are βloadedβ into the model, which may be the order of the DbSet or another order, if there is more relation - for example, some other object referring to AClass .
In the end, it makes no difference, because such a many-to-many relationship is "symmetrical." If you want to have your own connection table name, you can specify it in the Fluent API, as you already did.
So, to your question: Yes, naming the AuthorProjects connection table AuthorProjects is the correct behavior. If the name was ProjectAuthors , that would be the correct behavior, though.
source share