title: Many to Many Relationship with extra columns in EF 6 Code?
body: <p>Say if I have the classic example of Student and Courses. A student can have many courses and course can have many students.</p>
  
  <p>How do I make the middle table in EF 6 code if I wanted to add an extra field on the many table part?</p>
  
  <p>Do I just make in code another class and then hook it up somehow?</p>
  
  <p>DB Context</p>
  
  <pre><code>public class MyContext : DbContext
  {
      public MyContext (string nameOrConnectionString) : base(nameOrConnectionString)
      {
          // this.Configuration.ProxyCreationEnabled = false;
          Database.SetInitializer(new CreateDatabaseIfNotExists&lt;OSPContext&gt;());
      }
  
      public DbSet&lt;Student&gt; Students { get; set; }
      public DbSet&lt;Course&gt; Courses { get; set; }
  
      public DbSet&lt;StudentCourse&gt; StudentCourses { get; set; }
  
  }
  
  
  public class StudentCourse
  {
      [Key]
      public Guid StudentCourseId { get; set; }
  
      public Guid StudentId { get; set; }
  
      [ForeignKey("StudentId")]
      public virtual Student Student { get; set; } // Include this so you can access it later
  
      public Guid CourseId { get; set; }
  
      [ForeignKey("CourseId")]
      public virtual Course Course { get; set; }
  
      public int Permissions { get; set; }
  }
  
  public class Course
  {
      [Key]
      public  Guid Id { get; set; }
      public string Name { get; set; }
      public virtual ICollection&lt;Student&gt; Students { get; set; } = new &gt;();
  }
  
  public class Student
  {
      [Key]
      public  Guid Id { get; set; }
      public  string Email { get; set; }
      public virtual ICollection&lt;Course&gt; Courses { get; set; } = new List&lt;Course&gt;();
  
  }
  </code></pre>