I have an entity (Entity1
) which has a property of another entity (Entity2
). The database is set up correctly and when I insert a new row for Entity1
, the foreign key value is correct and I can insert infinite number of rows for Entity1
and they all reference Entity2
correctly.
However, when I make a change to Entity1
, call Attach()
and then try to save those changes, I'm getting a SQL exception that says it can't insert a new row for Entity2
because IDENTITY_INSERT
is not on.
I obviously don't want to do anything with Entity2
- definitely not insert a new row, I just want to update values in the Entity1
table.
I am using an adapter pattern to adapt everything from my business models to my data entities and everything there looks fine.
I'm happy to supply code if you think that would help, but right now I'm just looking for some high level ideas of where to start chasing this one down.
TIA