Can I use Data Annotations to perform a Cascade Delete with Entity Framework 4.1 RC?

后端 未结 4 563
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 00:46

When using data annotations with EF4.1 RC is there an annotation to cause cascade deletes?

public class Category
{
    public int Id { get; set; }
    [Requi         


        
4条回答
  •  渐次进展
    2020-12-08 00:57

    Putting required on the Product table Category relationship field solves this

    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
    
        [Required]  //<======= Forces Cascade delete
        public Category Category { get; set; }
    }
    

提交回复
热议问题