Skip to content

What should happen when attaching an inconsistent entity? #1246

Closed
@ajcvickers

Description

@ajcvickers

Consider calling Attach, AttachGraph, or setting the state of an entity to Unchanged. The expectation is that the state of the entity will be Unchanged. However, what if the entity references a principal with a PK that doesn't match the FK in the new entity? We discussed this at length when implementing FK support in the old stack and came to the conclusion that we should throw a constraint exception. One of the alternatives was to fixup the FK and mark the entity as Modified. This is currently the behavior in the new stack for AttachGraph, and may not be totally unreasonable given:

  • This shouldn't happen if the graph is really being attached after being disconnected
  • If the graph wasn't disconnected but was instead just constructed, then fixing up the FK may be the correct thing to do anyway
  • The exception might help you find a bug in your code, but otherwise doesn't seem useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions