title: EF 4.2 Code First. How to name a many-to-many table?
body: <p>Is it possible to specify the table name in a many-to-many relationship?</p>
  
  <p>Example:</p>
  
  <pre><code>class A
  {
      public int Id { get; set; }
      // .....
  
      public virtual ICollection&lt;B&gt; BCollection { get; set; }
  }
  
  class B
  {
      public int Id { get; set; }
      // .....
  
      public virtual ICollection&lt;A&gt; ACollection { get; set; }
  }
  </code></pre>
  
  <p>I thought that this could maybe work but apparently it doesn't.</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;A&gt;().HasMany(x =&gt; x.BCollection).WithMany(y =&gt; y.ACollection).Map(m =&gt; m.ToTable("My_Custom_Name"));
  }
  </code></pre>