Skip to content
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

Throw if identifying foreign key is still unknown when saving changes #19405

Merged
merged 1 commit into from
Dec 30, 2019

Commits on Dec 26, 2019

  1. Throw if identifying foreign key is still unknown when saving changes

    Fixes #13666
    
    Investigated this in more detail. Two `Object` (this is a custom `Object` class, not the normal `System.Object` type) entities are created. The first one is directly associated with a Container. The second one has no Container reference or FK set. However, because the FK is also part of the PK, and the PK uses generated values, it means that the FK gets a value set.
    
    We do this to handle dependents encountered before principals when attaching the graph. But the intention here is that the dummy key value generated will be replaced once the principal is attached. If this doesn't happen, then SaveChanges will throw due to the FK constraint violation. This change provides clarity by failing in SaveChanges so we avoid ever sending the dummy value to the database.
    ajcvickers committed Dec 26, 2019
    Configuration menu
    Copy the full SHA
    275286a View commit details
    Browse the repository at this point in the history