Can a table name be specified in a many-to-many relationship?
Example:
class A { public int Id { get; set; } // ..... public virtual ICollection<B> BCollection { get; set; } } class B { public int Id { get; set; } // ..... public virtual ICollection<A> ACollection { get; set; } }
I thought this might work, but it doesn't seem to be.
protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<A>().HasMany(x => x.BCollection).WithMany(y => y.ACollection).Map(m => m.ToTable("My_Custom_Name")); }
source share