The DELETE statement conflicted with the SAME TABLE REFERENCE constraint with Entity Framework

前端 未结 3 1118
梦如初夏
梦如初夏 2021-01-01 18:15

I have a table with a self reference where the ParentId is an FK to the ID (PK).
Using EF (code-first), I\'ve set up my relationship as follows:

this.Ha         


        
3条回答
  •  囚心锁ツ
    2021-01-01 19:21

    There is another way, (think about the draw backs before doing it ... ) you can set the relationship to be ON DELETE CASCADE, and try to delete just the parent row.

提交回复
热议问题