Код EF Первый каскад удалить и обновить?
Мои сущности это:
<code>public class Customer { public Customer() { Invoices = new List<Invoice>(); Payments = new List<Payment>(); } public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public IList<Payment> 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>
и это мой контекст:
<code>public class AccountingContext : DbContext, IDisposable { public DbSet<Customer> Customers { get; set; } public DbSet<Payment> Payments { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); modelBuilder.Entity<Payment>() .HasRequired(s => s.Customer) .WillCascadeOnDelete(); base.OnModelCreating(modelBuilder); } } </code>
я получаю эту ошибку вWillCascadeOnDelete():
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
я хочу удалить платежи каскада клиентов (Just if клиент удаляется). Как я могу достичь этого в коде EF в первую очередь?
Также я хочу использовать каскадное обновление. пожалуйста, помогите мне в этих вопросах. Thanx.