title: EF6 Code First - may cause cycles or multiple cascade paths
body: <p>I'm using EF6 Code First.
  I have two classes:</p>
  
  <pre><code>public class Player
  {
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      [Key]
      public int Id { get; set; }
  
      [Required, MinLength(2, ErrorMessage = "Player name must be at least 2 characters length")]
      public string Name { get; set; }
  
      [Required]
      public int TeamClubId { get; set; }
  
      [Required]
      public int TeamNationalId { get; set; }
  
      [Required, ForeignKey("TeamClubId")]
      public virtual Team Club { get; set; }
  
      [Required, ForeignKey("TeamNationalId")]
      public virtual Team National { get; set; }
  
  }
  </code></pre>
  
  <p>And: </p>
  
  <pre><code> public class Team
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }
  
      [Required, MinLength(2, ErrorMessage = "Team name must be at least 2 characters length")]
      public string Name { get; set; }
  
      [Required]
      public TeamType Type { get; set; }
  
      public virtual ICollection&lt;Player&gt; Players { get; set; }
  }
  </code></pre>
  
  <p>These are my two class with their relationship.
  A player belongs to two teams: club and national teams.
  A team can be either club or national, and holds a collection of player.</p>
  
  <p>In my context file I use:</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Player&gt;()
                  .HasRequired&lt;Team&gt;(p =&gt; p.National)
                  .WithMany(t =&gt; t.Players)
                  .WillCascadeOnDelete(false);
  
          base.OnModelCreating(modelBuilder);
      }
  </code></pre>
  
  <p>When running the migration tool to update the database, I get the following error:</p>
  
  <p>Introducing FOREIGN KEY constraint 'FK_dbo.Players_dbo.Teams_TeamNationalId' on table 'Players' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
  Could not create constraint. See previous errors.</p>
  
  <p>How do I solve it?</p>