0

Consider the following model classes:

 public class Thing
{
    public int Id { get; set; }
    [Required]
    public Text Subject { get; set; }
    [Required]
    public Text Body { get; set; }
}

public class Text
{
    public int Id { get; set; }
    public string Value { get; set; }
}

The model is simple - each Thing must reference to two Text entities. Each Text entry at any point in time should be referenced only by a single entity of any other type (Thing is not the only one).

Is it possible to configure EF5 to automatically delete all referenced Texts when Thing gets deleted (via context.Set<Thing>().Remove), or should it be done with a database trigger?

4

1 回答 1

0

您只需要CASCADE DELETE在数据库级别进行配置,而不必在实体框架级别做任何特别的事情。

于 2012-11-07T09:15:07.497 回答