title: Entity Framework 6 foreign key
body: <p>I am coding an MVC5 internet application with EF6, and have a question in regards to a foreign key name.</p>
  
  <p>I have a model called <code>MapLocationList</code> that has these two fields:</p>
  
  <pre><code>public int mapLocationListGalleryId { get; set; }
  public virtual MapLocationListGallery mapLocationListGallery { get; set; }
  </code></pre>
  
  <p>When EF creates the table, there is both the following columns:</p>
  
  <ul>
  <li>mapLocationListGalleryId  </li>
  <li>MapLocationListGallery_Id</li>
  </ul>
  
  <p>Can someone please explain why there are two columns for the <code>MapLocationListGallery</code> foreign key?</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have changed the name to use an uppercase M, yet the additional column is still there.</p>
  
  <p>Here is my model:</p>
  
  <pre><code>public class MapLocationList : IMapLocationItemWithAssets
  {
      [Key]
      public int Id { get; set; }
      [Required]
      public string name { get; set; }
      public bool enabled { get; set; }
      [ScaffoldColumn(false)]
      public string mapLocationItemType { get; set; }
      [ScaffoldColumn(false)]
      public string userName { get; set; }
      [ScaffoldColumn(false)]
      public DateTime creationDate { get; set; }
      [ScaffoldColumn(false)]
      public DateTime lastUpdate { get; set; }
      public string thumbnailDisplayText { get; set; }
      public bool parentIsMapLocation { get; set; }
      public int thumbnailAssetId { get; set; }
      public virtual Asset thumbnailAsset { get; set; }
      public int mapLocationId { get; set; }
      public virtual MapLocation mapLocation { get; set; }
      public int mapLocationListGalleryId { get; set; }
      public virtual MapLocationListGallery mapLocationListGallery { get; set; }
  
      public virtual ICollection&lt;MapLocationListItem&gt; listItems { get; set; }
  
      public MapLocationList()
      {
          creationDate = DateTime.Now;
          lastUpdate = DateTime.Now;
          listItems = new List&lt;MapLocationListItem&gt;();
      }
  }
  </code></pre>
  
  <p>I also have the following in the <code>OnModelCreating</code> function:</p>
  
  <pre><code>modelBuilder.Entity&lt;MapLocationListGallery&gt;()
      .HasRequired(c =&gt; c.thumbnailAsset)
      .WithMany()
      .WillCascadeOnDelete(false);
  
  modelBuilder.Entity&lt;MapLocationList&gt;()
      .HasRequired(c =&gt; c.thumbnailAsset)
      .WithMany()
      .WillCascadeOnDelete(false);
  
  modelBuilder.Entity&lt;MapLocationList&gt;()
      .HasRequired(c =&gt; c.mapLocationListGallery)
      .WithMany()
      .WillCascadeOnDelete(false);
  
  modelBuilder.Entity&lt;MapLocationListItem&gt;()
      .HasRequired(c =&gt; c.thumbnailAsset)
      .WithMany()
      .WillCascadeOnDelete(false);
  </code></pre>