❔ Troubleshooting EF Core: Error Message - INSERT Statement Conflicts with FOREIGN KEY Constraint
Hey there facing an issue,
I got a lesson entity that contains a List of questions.
Mapping is done like this:
I am getting an exception when attempting to insert a new lesson, and my assumption is that the foreign key constraint on the questions array is failing because the lesson does not yet have an ID. As a result, the questions array is missing the required foreign key reference to the newly created lesson. Here is an example of the JSON data I am using:
Method like this:
I got a lesson entity that contains a List of questions.
Mapping is done like this:
I am getting an exception when attempting to insert a new lesson, and my assumption is that the foreign key constraint on the questions array is failing because the lesson does not yet have an ID. As a result, the questions array is missing the required foreign key reference to the newly created lesson. Here is an example of the JSON data I am using:
Method like this: