title: Why EF doesn't create second foreign key column in SQL table?
body: <p>I'm trying to create an entity (Link) that is related to two other entities (Domain, Subpage) so Link Table will have two columns ID and SubpageID. Basically I'm trying to create 2 one-to-many relationship where Domain object and Subpage object can be mapped to many Link objects and each Link object is related only to one Domain and Subpage object. </p>
  
  <p><strong>Link model</strong></p>
  
  <pre><code> public class Link
      {
          [Key]
          public int LinkID { get; set; }
  
          ...
  
          [Required]
          public int ID { get; set; }
          public virtual Domain Domain { get; set; }
          [Required]
          public int SubpageID { get; set; }
          public virtual Subpage Subpage { get; set; }
      }
  </code></pre>
  
  <p><strong>Domain model</strong></p>
  
  <pre><code>public class Domain
      {
          public int ID { get; set; }
  
          ...
  
          ICollection&lt;Link&gt; Links { get; set; }
      }
  </code></pre>
  
  <p><strong>Subpage model</strong></p>
  
  <pre><code> public class Subpage
      {
          [Key]
          public int SubpageID { get; set; }
  
          ...
  
          [Required]
          public int ID { get; set; }
          public virtual Domain Domain { get; set; }
  
          ICollection&lt;Link&gt; Links { get; set; }
  
      }
  </code></pre>
  
  <p><strong>DbContext</strong></p>
  
  <pre><code>public class DomainAppContext : DbContext
      {
          public DbSet&lt;Domain&gt; Domains { get; set; }
          public DbSet&lt;RegInfo&gt; RegInfos { get; set; }
          public DbSet&lt;Subpage&gt; Subpages { get; set; }
          public DbSet&lt;Link&gt; Links { get; set; }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              modelBuilder.Conventions.Remove&lt;OneToManyCascadeDeleteConvention&gt;();
          }
  
      }
  </code></pre>
  
  <p><strong>After resolving problems with Cascade Delete etc. I've noticed that Link Table doesn't have an SubpageID column</strong> and I have no idea why...</p>
  
  <p>How can I force EF to create SubpageID column on Link table?</p>