none
Orphan records

Answers

  • No, the Entity Framework does not have a mechanism for this.  You would have to build something like this in your application logic outside the EF.  Sorry. 

     

    Friday, May 30, 2008 3:29 PM

All replies

  • Here are some clarifications:

    I have entity A which is associated with another entity B. "A" can have one instance of B and when I change this instance
    with new one I want old entity B to be deleted from database.

    Are there features in ADO.NET 3.5 similar to the cascade="delate-all-orphan" attribute in NHibernate?

    Let's consider the following model:

    1. Entity Product
    - ID : int
    - Name : string
    - Category : ProductCategory

    2. Entity ProductCategory
    - ID : int
    - Name : string
    - Products : EntityCollection<Product>

    We have the following code:

    product1.Category = category1;
    product1.Category = category2;

    No other product have its Category associated to category1. Is there a way to automatically delete category1 from the DB?

    Thanks
    Thursday, May 29, 2008 4:09 PM
  • No, the Entity Framework does not have a mechanism for this.  You would have to build something like this in your application logic outside the EF.  Sorry. 

     

    Friday, May 30, 2008 3:29 PM