Join GitHub today
SQL Server: Switch IDENTITY_INSERT on (and then off) when explicit values are specified for an identity column #703
When using generated values the state manager will not generate a temporary value if a specific value was already set. The update pipeline should then handle inserting the specific value or throw an exception. This isn't currently implemented for Identity columns in SQL Server. (It is also an option that the update pipeline could somehow special case this situation using metadata information and still generate a new value, just as it did in the old stack, but this would be a break from the expected behavior for value generation.)
referenced this issue
Apr 3, 2015
With the implementation we landed on you will get an exception if you try to specify explicit values... but it is possible to make it work with a bit of extra code.
We could be smart about this in our provider and actually switch IDENTITY_INESRT on then off when we know that we're going to try and insert and explicit value.