TheJoeIaut
TheJoeIaut

Reputation: 1532

Entity Framework Handle Deletion of Entities

I am quite new to EF and i am stumbling uppon finding a clean solution, for deleting reference Entities:

public class UserAccess : CloneableBaseEntity<UserAccess>
{
    public User User { get; set; }
    public Site Site { get; set; }
    public CostCenter CostCenter { get; set; }
    public Product Product { get; set; }
}

Case 1:

When a User is deleted, also the User Access should be deleted

Case 2

When a Product is deleted the Useraccess should be still there.

Any ideas?

Upvotes: 0

Views: 99

Answers (1)

Dandr&#233;
Dandr&#233;

Reputation: 2173

Mark the relationship between User and UserAccess to have a Cascade Delete.

Upvotes: 1

Related Questions