EF Code Pierwsze kasowanie i aktualizacja?
Moje podmioty to te:
<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>
i to jest mój kontekst:
<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>
dostaję ten błądWillCascadeOnDelete ():
Błąd 1 „System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration” nie zawiera definicji „WillCascadeOnDelete” ani żadnej metody rozszerzenia „WillCascadeOnDelete” przyjmującej pierwszy argument typu „System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration” można znaleźć (czy brakuje dyrektywy używającej lub odwołania do zestawu?) D: Projekty C # Visual Studio 2010 Windows WPF Nowy folder Księgowanie bez kodu EF Pierwsze Księgowanie - Kopiowanie DAL.EF.CodeFirst Elementy Kontekst AccountingContext.cs 22 22 DAL.EF.CodeFirst
Chcę usunąć płatności kaskadowe klienta (Tylko jeśli usunięcie klienta). jak mogę to osiągnąć w kodzie EF?
chcę też użyć aktualizacji kaskadowej. proszę mi pomóc w tych sprawach. thanx.