title: EF Foreign Key constraint
body: <p>I'm still studying Entity Framework and tried to create a model including the foreign keys.</p>
  <p>But when I tried to migrate the code, I got this error</p>
  <blockquote>
  <p>Introducing FOREIGN KEY constraint 'FK_dbo.QuestionResults_dbo.QuestionsTables_QuetionsTableId' on table 'QuestionResults' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints</p>
  </blockquote>
  <p>These are my model classes:</p>
  <pre><code>public class MainDetails
  {
      [Key]
      public int Id { get; set; }
      public string Language { get; set; }
  
      [Required]
      public string CustomerName { get; set; }
  
      [Required]
      public string ContactNumber { get; set; }
      public string EmailAddress { get; set; }
  
      [DisplayName(&quot;Service Type&quot;)]
      [ForeignKey(&quot;QuestionsTable&quot;)]
      public int ServiceTypeId { get; set; }
      public virtual QuestionsTable QuestionsTable { get; set; }
  
      [Required]
      public string VehicleNumber { get; set; }
  
      [Required]
      public string ServiceLocation { get; set; }
      public string Suggestion { get; set; }
      public bool Status { get; set; } = true;
  
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = &quot;{0:yyyy-MM-dd}&quot;, ApplyFormatInEditMode = true)]
      [Display(Name = &quot;Created Date&quot;)]
      public DateTime CreatedDate { get; set; } = DateTime.Now;
  
      public virtual QuestionResults QuestionResults { get; set; }
  
      public virtual IList&lt;QuestionResults&gt; QuestionResultsMainlist { get; set; }
      public virtual IList&lt;QuestionsTable&gt; QuestionsTables { get; set; }
  }
  
  public class QuestionsTable
  {
      [Key]
      public int Id { get; set; }
      public string ServiceType { get; set; }
      public string Question { get; set; }
      public virtual IList&lt;MainDetails&gt; MainDetailsServiceType { get; set; }
      public QuestionsTable()
      {
          MainDetailsServiceType = new List&lt;MainDetails&gt;();
      }
  }
  
  public class QuestionResults
  {
      [Key]
      public int Id { get; set; }
  
      [DisplayName(&quot;MainDetail ID&quot;)]
      [ForeignKey(&quot;MainDetails&quot;)]
      public int MainDetailsId { get; set; }
      public virtual MainDetails MainDetails { get; set; }
  
      [DisplayName(&quot;MainDetail ID&quot;)]
      [ForeignKey(&quot;QuestionsTable&quot;)]
      public int QuetionsTableId { get; set; }
      public virtual QuestionsTable QuestionsTable { get; set; }
  
      [Required]
      public string CustoAnswer { get; set; }
  }
  </code></pre>
  <p>This is the table structure I wanted to create:</p>
  <p><a href="https://i.stack.imgur.com/RnKus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RnKus.png" alt="enter image description here" /></a></p>