title: Entity Framework Code First double relation to same class
body: <p>I have a <code>Page</code> class that is to be associated with similar pages. Each association has additional information about the association. This is the class that has been defined as the representation of a <code>Page</code>.</p>
  
  <pre><code>public class Page {
      [Key]
      public virtual int Id { get; protected set; }
      [Required]
      [StringLength(32)]
      public virtual string Name { get; set; }
      [InverseProperty("Page")]
      public virtual ICollection&lt;Association&gt; Associations { get; set; }
  }
  </code></pre>
  
  <p>Each page has can be associated with any number of other pages. This is to be defined as a source and a target page. I do not mind if the association is unidirectional or bidirectional, either will be justified in my particular scenario (I prefer bidirectional associations, tough). This is the association class..</p>
  
  <pre><code>public class Association {
      [Key, Column(Order = 0)]
      public virtual int PageId { get; protected set; } // SOURCE
      [Required]
      public virtual Page Page { get; set; } // SOURCE
      [Key, Column(Order = 1)]
      public virtual int TargetId { get; protected set; } // TARGET
      [Required]
      public virtual Page Target { get; set; } // TARGET
      [Required]
      [StringLength(32)]
      public virtual string InformationAboutTheAssociation { get; set; }
  }
  </code></pre>
  
  <p>Now I have the following context ...</p>
  
  <pre><code>public class DbCtx : DbContext {
      public DbSet&lt;Association&gt; Associations { get; set; }
      public DbSet&lt;Page&gt; Pages { get; set; }
  }
  </code></pre>
  
  <p>And the issue is that SQL Express is complaining about possible cyclic references (which is not the case, but it is over-protective). How do I solve the scheme that is generated to accept the described scenario?</p>
  
  <pre><code>Introducing FOREIGN KEY constraint 'FK_dbo.Associations_dbo.Pages_TargetId' on table 'Associations' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
  </code></pre>
  
  <p>Thanks!</p>