How to set on delete cascade for self reference Foreign Key in Entity Framework in ASP.NET
问题 I am developing an ASP.NET MVC project. I am using Entity Framework code first approach to interact with database. But I am having a problem with setting on cascade delete for self-reference foreign key for an entity. This is my entity class with self reference foreign key public class Category { public int Id { get; set; } [Required] [MaxLength(50)] public string Name { get; set; } [MaxLength(55)] public string MmName { get; set; } public int? ParentId { get; set; } [ForeignKey("ParentId")]