0

Possible Duplicate:
Delete an object and all of its related entities in Entity Framework

I have looked for a while on how to do this, but found none of the posts addressing this issue. These are the classes for setting up the db:

public class Claim
{
    [Key,DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.Identity)]
    public int DraftID { get; set; } 
    public int ClaimID { get; set; } 
    public string SupplierCode { get; set; }
    public ClaimStatus Status { get; set; }
    public Policy Policy { get; set; }
}

my context:

public class FnxDbContext:DbContext {
 public FnxDbContext() : base() { this.Configuration.ProxyCreationEnabled = false; } public DbSet<Claim> Claim { get; set; }

Now let's say I want to remove the Claim-entity with the DraftID that is "1" (there is such a record in the DB with FK to other tables as needed) How do I do this? I tried many ideas I found on the net. Most of them talk about a single entity. Can anyone help me with this issue?

Community
  • 1
  • 1
e e
  • 1
  • 2
  • you've got a context class (inherting from DbContext) and do override OnModelCreating ? if yes, can you show the part concerning the Claim Entity ? – Raphaël Althaus Jan 31 '13 at 09:51
  • my context: public class FnxDbContext:DbContext { public FnxDbContext() : base() { this.Configuration.ProxyCreationEnabled = false; } public DbSet Claim { get; set; } – e e Jan 31 '13 at 10:16
  • What do you want to remove? A single `Claim` plus the related `Status` plus the related `Policy`??? – Slauma Jan 31 '13 at 20:38
  • yes that is what i want @ do – e e Feb 03 '13 at 09:08

0 Answers0