title: One to Many relationship in Entity Framework
body: <p>I have a <code>Task</code> entity like this:</p>
  
  <pre><code>public class Task
  {
      public Guid Id { get; set; }
      public int  TaskOwnerId { get; set; }
      public virtual EPDUser TaskOwner { get; set; }
  
      public virtual List&lt;EPDUser&gt; TaskOwners { get; set; }
   }
  </code></pre>
  
  <p>And <code>EPDUser</code> entity is</p>
  
  <pre><code>public class EPDUser
  {
     public int ID { get; set; }
  }
  </code></pre>
  
  <p>What I am trying to do is, I am just maintaining <code>TaskOwners</code> who has held this task before (like history of reassign), that's why I have a list inside the <code>Task</code> entity, and the <code>TaskOwnerId</code> property holds current task owner id.</p>
  
  <p>I am trying to create a new mapping table like below,</p>
  
  <pre><code>modelBuilder.Entity&lt;Task&gt;()
              .HasMany(x =&gt; x.TaskOwners)
              .WithMany()
              .Map(x =&gt; x.MapLeftKey("TaskId")
                         .MapRightKey("TaskOwnerId")
                         .ToTable("TaskOwnerHistory"));
  </code></pre>
  
  <p>I got this error when tried to update my database.</p>
  
  <blockquote>
    <p>Introducing FOREIGN KEY constraint 'FK_dbo.TaskOwnerHistory_dbo.EPDUsers_TaskOwnerId' on table 'TaskOwnerHistory' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.<br>
    Could not create constraint. See previous errors.</p>
  </blockquote>
  
  <p>Kinldy help me to store the list of taskowners as history.</p>