title: Specifying ON DELETE NO ACTION in Entity Framework 7?
body: <p>In Entity Framework 7 when I am trying to apply a migration I get the error</p>
  
  <blockquote>
    <p>Introducing FOREIGN KEY constraint 'FK_ChangeOrder_User_CreatedByID' on table 'ChangeOrder' 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>I know in older versions of Entity Framework you would deal with this by adding</p>
  
  <pre class="lang-cs prettyprint-override"><code>modelBuilder.Conventions.Remove&lt;OneToManyCascadeDeleteConvention&gt;();
  </code></pre>
  
  <p>to the DbContext but in EF7 <code>modelBuilder</code> does not seem to have a <code>.Conventions</code> to it and google is only returning older EF 4 though EF 6 results.</p>
  
  <p>How do I specific the <code>ON DELETE NO ACTION</code> constraint in Entity Framework 7?</p>
  
  <p>Edit:
  The answer provided by Oleg will apparently do it per Foreign Key but I would like to do it globally as it will much easier to use one line of code to declare this globally then have to specify code it out for every single one of the hundreds of relationships I will end up having.</p>
  
  <p>Edit 2: Code for Oleg</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ChangeOrder
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int ID { get; set; }
  
      public Int16? ApprovedByID { get; set; }
      public Byte ApprovalStatusID { get; set; }
      public Int16 AssignedToID { get; set; }
      public Int16 CreatedByID { get; set; }
      public Byte CurrentStatusID { get; set; }
      public DateTime? DateApproved { get; set; }
      public DateTime? EndDate { get; set; }
      public Byte ImpactID { get; set; }
      public Byte PriorityID { get; set; }
      public DateTime? StartDate { get; set; }
      public Byte TypeID { get; set; }
  
      [Required]
      public string Name { get; set; }
  
      [Required]
      public string ReasonForChange { get; set; }
  
      [ForeignKey("ApprovedByID")]
      public User ApprovedBy { get; set; }
  
      [ForeignKey("ApprovalStatusID")]
      public ChangeApprovalStatus ApprovalStatus { get; set; }
  
      [ForeignKey("AssignedToID")]
      public User AssignedTo { get; set; }
  
      [ForeignKey("CreatedByID")]
      public User CreatedBy { get; set; }
  
      [ForeignKey("ImpactID")]
      public ChangeImpact Impact { get; set; }
  
      [ForeignKey("PriorityID")]
      public ChangePriority Priority { get; set; }
  
      [ForeignKey("TypeID")]
      public ChangeType ChangeType { get; set; }
  
      [ForeignKey("CurrentStatusID")]
      public ChangeStatus CurrentStatus { get; set; }
  }
  </code></pre>
  
  <pre class="lang-cs prettyprint-override"><code>public class JobSightDBContext : DbContext
  {
      protected override void OnModelCreating(ModelBuilder modelbuilder)
      {
          base.OnModelCreating(modelbuilder);
      }
  
      DbSet&lt;ChangeApprovalStatus&gt; ChangeApprovalStatus { get; set; }
      DbSet&lt;ChangeImpact&gt; ChangeImapct { get; set; }
      DbSet&lt;ChangeOrder&gt; ChangeOrders { get; set; }
      DbSet&lt;ChangePriority&gt; ChangePriorities { get; set; }
      DbSet&lt;ChangeStatus&gt; ChangeStatus { get; set; }
      DbSet&lt;ChangeType&gt; ChangeTypes { get; set; }
      DbSet&lt;User&gt; Users { get; set; }
  }
  </code></pre>