-
Notifications
You must be signed in to change notification settings - Fork 54
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
Unexpected Duplicate FK Record inserted #132
Comments
I solved this by doing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm kind of a Postgresql newbie here. Not sure if this is a bug or not.
Scenario:
table Author {ID, AuthorName, BirthYear}
table Books {ID, AuthorID, BookName, PublishYear}
in EF Models
there would be a "public virtual Author Author {get;set;}" statement.
in the past when I use EF for MSSQL
I would do
_book.Author=_author;
db.Authors.Add(_author);
db.Books.Add(_book);
then _book.AuthorID would be automatically filled with ID value of newly added _author record
yet in Postgresql
I find that the same behavior would cause two _author record inserted to the table, with different ID value.
I'm not sure whether there's any way to fix it?
The text was updated successfully, but these errors were encountered: