SqlBulkCopy Insert with Identity Column

To have the destination table assign the identity, DO NOT use the SqlBulkCopyOptions.KeepIdentity option. Instead, don't map the identity from the source, and don't extract it from source to send through to SqlBulkCopy.


Fill the ColumnMapping of the BulkCopy object and don't map the identity column. The identity column will be generated by the target database.


You have two options -

1 - use KeepIdentity and preserve the source's Identity values.

2 - Don't map the Identity field. If you don't try to assign a value the target table will assign one automatically.