Entity Framework Cascading Delete

前端 未结 2 783
鱼传尺愫
鱼传尺愫 2021-01-23 14:33

First of all, apologies if I\'m missing some basic stuff here but I\'m new to EF and still getting my head around setting up the DB code first....

I\'m having a

2条回答
  •  佛祖请我去吃肉
    2021-01-23 15:27

    You need to make ActorID in your UseCase class as a nullable int. EF is throwing that error because it sees 2 foreign keys that are required in a single class. Having that would create multiple cascade paths--something that SQL Server is, unfortunately, ill-equipped to handle.

    In any case, making Actor optional on your UseCase class will mean that the Actor won't be deleted when the UseCase is, which I believe is your intent.

提交回复
热议问题