You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all it does not seem to work to have to FKs referencing the same table. According to what I understand this might be a limitation in SQL, and handled by triggers instead.
Question:
Is there a proper way to make this work using the fluent api, i.e. using cascade or trigger?
Issue:
No way to make it not throw the exception below. I.e. no way to not generate onDelete: ReferentialAction.NoAction in the migration file. Have tried the different onDelete options but it does not work..The suggested "ON DELETE NO ACTION" does not seem to be available using the fluent api?
(I still think the FKs should be required to at least throw exception if not handled on delete, so i don't think optional is good)
Exception message:
System.Data.SqlClient.SqlException: 'Introducing FOREIGN KEY constraint 'FK_PageVariations_Pages_VariationPageId' on table 'PageVariations' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other
FOREIGN KEY constraints.
Steps to reproduce
Create an entity with two required foreign keys to the same table
The text was updated successfully, but these errors were encountered:
@PetterT2 Both Restrict and ClientSetNull should work for this and give the same behavior in the database. If that's not the case, then please file a small, runnable project/solution or complete code listing that demonstrates the behavior you are seeing.
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.
First of all it does not seem to work to have to FKs referencing the same table. According to what I understand this might be a limitation in SQL, and handled by triggers instead.
Question:
Is there a proper way to make this work using the fluent api, i.e. using cascade or trigger?
Issue:
No way to make it not throw the exception below. I.e. no way to not generate onDelete: ReferentialAction.NoAction in the migration file. Have tried the different onDelete options but it does not work..The suggested "ON DELETE NO ACTION" does not seem to be available using the fluent api?
(I still think the FKs should be required to at least throw exception if not handled on delete, so i don't think optional is good)
is missing the NoAction which is an option in the migration files:
onDelete: ReferentialAction.NoAction
Exception message:
System.Data.SqlClient.SqlException: 'Introducing FOREIGN KEY constraint 'FK_PageVariations_Pages_VariationPageId' on table 'PageVariations' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other
FOREIGN KEY constraints.
Steps to reproduce
Create an entity with two required foreign keys to the same table
The text was updated successfully, but these errors were encountered: