I am trying to do record inserts on a table where the Primary Key is an Identity
field.
I have tried calling
mycontext.ExecuteCommand("SET identity_insert myTable ON")
but this doesn't do any good.
I get an error saying IDENTITY_INSERT
is OFF
when I submit changes.
How can I turn it ON
from the C# code before I submit changes?
EDIT
I have read that this is because ExecuteCommand's code gets executed in a different session.
EDIT 2
Is there any way I can execute some DDL to remove the Identity Specification from my C# code, do the inserts, and then turn Identity Specification back on?