Ive been trying to update my database with these three classes, Product, CartItem, and ProductAttribute (, but gives me an error that there is a cycle and that the delete actions must be specified. Now I have tried to make it such that if the Product gets deleted, then the CartItem and the Product Attribute also gets deleted but if the CartItem or the Product Attribute is deleted, then the Product will not be deleted. I have tried to add rules (plus new migration and updating) but I keep getting the same error:
Introducing FOREIGN KEY constraint ‘FK_CartItems_Products_ProductId’ on table ‘CartItems’ may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index. See previous errors.
I cannot understand why the error is still occurring despite trying so many ways of coding the rules but none of them works. Could it be that the rules are written wrong? Could it be that my models are the problem? I would really appreciate the help. I am currently using .NET6