當我刪除一臺計算機時,有什麼辦法可以讓刪除級聯發生?基本上,當我刪除一臺計算機時,我希望它刪除實例及其所有參考,但環境和產品除外。EF5代碼第一個級聯刪除
計算機實體:
public class Computer
{
[Key]
public int Id { get; set; }
public string IpAddress { get; set; }
public string Name { get; set; }
public string UserFriendlyName { get; set; }
public string Description { get; set; }
}
實例實體:
public class Instance
{
public Instance()
{
TestResults = new HashSet<TestResult>();
Environments = new HashSet<Environment>();
}
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public string UserFriendlyName { get; set; }
public virtual Product Product { get; set; }
public virtual Profile LastKnownProfile { get; set; }
public virtual Computer Computer { get; set; }
public virtual ICollection<TestResult> TestResults { get; set; }
public virtual ICollection<Environment> Environments { get; set; }
}
非常感謝。我已經爲該鏈接添加了書籤。 – twreid 2013-02-11 14:52:33