title: EF core and creating a many to many table. Creates extra field. Why ?
body: <p>Why is there a UserProgramRefProgramCharacteristics.RefProgramCharacteristicsId field???  There should only be 2 fields not 3. Right? Below are the 3 classes and the OnModelCreating that is needed to create a many to many table</p>
  
  <pre><code>  public class RefProgramCharacteristic
  {
      public int Id { get; set; }
  
      public string ProgramCharacteristic { get; set; }
  
       public List&lt;UserProgramRefProgramCharacteristic&gt; UserProgramRefProgramCharacteristics { get; set; }
  
      // public ICollection&lt;UserProgram&gt; userPrograms { get; } = new List&lt;UserProgram&gt;();
  
     // public virtual ICollection&lt;UserProgram&gt; UserPrograms { get; set; }
  }
  
  
    public class UserProgram
  {
      public int Id { get; set; }
  
      //UserProgramSaved
      public bool MyList { get; set; }
      public float MyPriorityRating { get; set; }
      public int Similarity { get; set; }
      public bool Compare { get; set; }
  
      //UserProgramSimilarity
      public int OverallSimilarityScore { get; set; }
      public int DeltaProfileElement1_WorkExp { get; set; }
      public int DeltaProfileElement2_VolExp { get; set; }
      public int DeltaProfileElement3_ResExp { get; set; }
      public int DeltaProfileElement4_Pubs { get; set; }
      public int DeltaProfileElement5_Step1 { get; set; }
      public int DeltaProfileElement6_Step2ck { get; set; }
      public int DeltaProfileElement7_Aoa { get; set; }
      public int DeltaProfileElement8_Nspecialties { get; set; }
      public int DeltaProfileElement9_PercentApps { get; set; }
  
      //UserComparisonSaved
      //  public RefProgramCharacteristic RefProgramCharacteristic { get; set; }
      public string RefProgramCharacteristicList { get; set; }
  
  
      public string ApplicationUserId { get; set; }
      public ApplicationUser ApplicationUser { get; set; }
  
  
      public int MedicalProgramId { get; set; }
      public RefProgramDetailData MedicalProgram { get; set; }
  
  
       public List&lt;UserProgramRefProgramCharacteristic&gt; UserProgramRefProgramCharacteristics { get; set; }
  
     // public ICollection&lt;RefProgramCharacteristic&gt; RefProgramCharacteristics { get; } = new List&lt;RefProgramCharacteristic&gt;();
  
     // public virtual ICollection&lt;RefProgramCharacteristic&gt; RefProgramCharacteristics { get; set; }
  
  
  }
  
  
     public class UserProgramRefProgramCharacteristic
  {
    //  public int Id { get; set; }
  
      public int UserProgramId { get; set; }
      public UserProgram UserProgram { get; set; }
  
  
      public int RefProgramCharacteristicsId { get; set; }
      public RefProgramCharacteristic RefProgramCharacteristic { get; set; }
  }
  
  
    protected override void OnModelCreating(ModelBuilder builder)
      {
          builder.Entity&lt;UserProgramRefProgramCharacteristic&gt;()
              .HasKey(t =&gt; new { t.UserProgramId, t.RefProgramCharacteristicsId });
  
          base.OnModelCreating(builder);
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mPI6o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPI6o.png" alt="Sql Diagram"></a></p>