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
In this case both Blog and Post are treated as new entity instances that need to be inserted. Instead you can use Attach such that the key being set will indicate that the Blog actually already exists:
I am trying to define a one-to-many relationship as follows:
The EF defined the relation as required by adding a new column BlogId as a foreign key
but when trying to create the Post below:
and I have previously created a Blog with Id = 1, the exception below is thrown
which mean that EF tries to create the referenced blog.
The text was updated successfully, but these errors were encountered: