Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths - why?

前端 未结 18 1255
天涯浪人
天涯浪人 2020-11-22 02:37

I\'ve been wrestling with this for a while and can\'t quite figure out what\'s happening. I have a Card entity which contains Sides (usually 2) - and both Cards and Sides h

18条回答
  •  独厮守ぢ
    2020-11-22 03:14

    I had this issue also, I solved it instantly with this answer from a similar thread

    In my case, I didn't want to delete the dependent record on key deletion. If this is the case in your situation just simply change the Boolean value in the migration to false:

    AddForeignKey("dbo.Stories", "StatusId", "dbo.Status", "StatusID", cascadeDelete: false);
    

    Chances are, if you are creating relationships which throw this compiler error but DO want to maintain cascade delete; you have an issue with your relationships.

提交回复
热议问题