title: EF Code First cascade delete and update?
body: <p>My entities are these:</p>
  
  <pre><code>public class Customer
  {
      public Customer()
      {
          Invoices = new List&lt;Invoice&gt;();
          Payments = new List&lt;Payment&gt;();
      }
  
      public int ID { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  
      public IList&lt;Payment&gt; Payments { get; set; }
  }
  
  public class Payment
  {
      public int ID { get; set; }
      public int CustomerID { get; set; }
      public decimal CreditPrice { get; set; }
      public decimal DebitPrice { get; set; }
      public DateTime PaymentDate { get; set; }
  
      [ForeignKey("CustomerID")]
      public Customer Customer { get; set; }
  }
  </code></pre>
  
  <p>and this is my context:</p>
  
  <pre><code>public class AccountingContext : DbContext, IDisposable
  {
      public DbSet&lt;Customer&gt; Customers { get; set; }
      public DbSet&lt;Payment&gt; Payments { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
  
          modelBuilder.Entity&lt;Payment&gt;()
                  .HasRequired(s =&gt; s.Customer)
                  .WillCascadeOnDelete();
  
          base.OnModelCreating(modelBuilder);
      }
  }
  </code></pre>
  
  <p>i get this error in <em>WillCascadeOnDelete()</em>:</p>
  
  <blockquote>
    <p>Error 1   'System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration' does not contain a definition for 'WillCascadeOnDelete' and no extension method 'WillCascadeOnDelete' accepting a first argument of type 'System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration' could be found (are you missing a using directive or an assembly reference?)   D:\Work\C# Projects\Visual Studio 2010\Windows\WPF\New folder\Accounting Without EF Code First\Accounting - Copy\DAL.EF.CodeFirst\Entities\Context\AccountingContext.cs 22  22  DAL.EF.CodeFirst</p>
  </blockquote>
  
  <p>i want to delete payments of the customer cascading (<strong>Just if</strong> customer getting deleted). how can i achieve this in EF code first?</p>
  
  <p>also i want to use cascade update.
  please help me in these issues.
  thanx.</p>