@David Thielen, Welcome to Microsoft Q&A,
Is this the correct way to tell EF that when deleting a User object, it should not cascade its child Signup objects?
Based on my test and research, it seems that EF Core does not allow you to do it.
Please refer to the Microsoft Learning Fields about NoAction
, which has the following sentence:
If a property cannot be set to null because it is not a nullable type, then an exception will be thrown when
SaveChanges()
is called.
Also, based on my test, it indeed throws the exception that does not allow you to delete User objects and Signup objects when I delete a User Object.
If you just want to delete child objects, I recommend that you could delete the foreign key in database and then you could delete the User object and not delete child Signup objects
Based on my test, it only deleted child objects and did not delete the parent objects.
Hope my explanations could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.