title: Code First Entity Framework adds an underscore to a primary key column name
body: <p>I have a fluent mapping of a domain class that defines the names for each column including the primary key which is made up of two columns, NotificationId and IdentityId. These are also foreign keys that point at Notification.Id and Identity.Id respectively. Whenever I use this mapping as part of a query it generates a sql query with an underscore in between Notification and Id (Notification_Id) that is not mentioned anywhere in my mappings.</p>
  
  <p>I would expect that there might be some convention that says that primary keys or foreign keys should look like that but it seems odd given that I've explicitly told it what the column name for NotificationId is.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Added mapping file</p>
  
  <pre><code>public class Notifications_IdentitiesMap : EntityTypeConfiguration&lt;Notifications_Identities&gt;
  {
      public Notifications_IdentitiesMap()
      {
          ToTable("Notifications.Notifications_Identities");
          HasKey(x =&gt; new { x.NotificationId,x.IdentityId });
          Property(x =&gt; x.IdentityId).HasColumnName("IdentityId").HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
          Property(x =&gt; x.NotificationId).HasColumnName("NotificationId").HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
          Property(x =&gt; x.SendAttempts).HasColumnName("SendAttempts");
          Property(x =&gt; x.IsSent).HasColumnName("IsSent");
          Property(x =&gt; x.LastSendAttempt).HasColumnName("LastSendAttempt");
          HasRequired(x =&gt; x.Notification).WithMany().HasForeignKey(x =&gt; x.NotificationId);
          HasRequired(x =&gt; x.Identity).WithMany().HasForeignKey(x =&gt; x.IdentityId);
      }
  }
  public class Notifications_Identities
  {
  
      public Notifications_Identities()
      {
  
      }
      public Notifications_Identities(Notification notification, int identityId)
      {
          Notification = notification;
          IdentityId = identityId;
      }
      public virtual int IdentityId { get; set; }
      public virtual int NotificationId { get; set; }
      public virtual int SendAttempts { get; set; }
      public virtual DateTime? LastSendAttempt { get; set; }
      public virtual Identities.Identity Identity { get; set; }
      public virtual Notification Notification { get; set; }
      public bool IsSent { get; set; }
  }
  public class NotificationMap:EntityTypeConfiguration&lt;Notification&gt;
  {
      public NotificationMap()
      {
          ToTable("Notifications.Notifications");
          Property(x =&gt; x.Id).HasColumnName("Id");
          Property(x =&gt; x.Subject).HasColumnName("Subject").HasMaxLength(255);
          Property(x =&gt; x.Message).HasColumnName("Message");
          Property(x =&gt; x.TypeId).HasColumnName("TypeId");
          Property(x =&gt; x.DateCreated).HasColumnName("DateCreated");
          Property(x =&gt; x.CreatorIdentityId).HasColumnName("CreatorIdentityId");
  
          HasRequired(x =&gt; x.Creator).WithMany().HasForeignKey(x =&gt; x.CreatorIdentityId);
      }
  }
  public class IdentityMap : EntityTypeConfiguration&lt;RM.Domain.Identities.Identity&gt;
      {
          public IdentityMap()
          {
              Property(x =&gt; x.Id).HasColumnName("IDENTITYID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
              Property(x =&gt; x.FirstName).HasColumnName("firstname");
              Property(x =&gt; x.Surname).HasColumnName("surname");
              Property(x =&gt; x.Username).HasColumnName("username");
              Property(x =&gt; x.IsGroup).HasColumnName("is_group");
              Property(x =&gt; x.EmailAddress).HasColumnName("email");
              Property(x =&gt; x.ActiveDirectoryId).HasColumnName("ActiveDirectoryId");
              Property(x =&gt; x.IsLive).HasColumnName("is_active");
              ToTable("dbo.rm_tbl_IDENTITY_Identities");
          }
      }
  </code></pre>