-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a composite object? #4847
Comments
As this exception says Insert statement failed because it violated the Foreign key constraint. There is a foreign key constraint on Parent table with P.S. |
Hi!
I use EF Core.
There is the following composite object, for example:
Parent and Child has one-to-one relation:
I try to create new Parent with Child and save it in the DB:
and get the following exception:
If I use the db context to create a child it works fine:
Question 1: I can easily add new entities to a nested collections without using context for create it. But it not works for one-to-one relation. For example:
Why?
Question 2: Please, describe me what I do wrong and how I can save new parent with a child without context to create a child (like nested collections)?
Thank you!
The text was updated successfully, but these errors were encountered: