You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing a bulk insert with SqlBulkCopyOptions.KeepIdentity, the expected behaviour is that IDs provided in the entity list should be inserted as-is. However, due to how default values are handled in InnerGetDataTable, NULLs are inserted instead, leading SQL Server to generate new IDs.
Steps to Reproduce:
Create an entity with a GUID primary key.
Populate a list of entities with pre-generated IDs.
When performing a bulk insert with
SqlBulkCopyOptions.KeepIdentity
, the expected behaviour is that IDs provided in the entity list should be inserted as-is. However, due to how default values are handled inInnerGetDataTable
, NULLs are inserted instead, leading SQL Server to generate new IDs.Steps to Reproduce:
BulkInsertAsync
withKeepIdentity
:Expected Behaviour:
The provided IDs should be inserted into the identity column.
Actual Behaviour:
NULLs are inserted instead, causing SQL Server to generate new IDs.
Root Cause:
The logic in
InnerGetDataTable
excludes columns with default values during insertProposed Fix:
Modify
hasDefaultValueOnInsert
to check forKeepIdentity
before excluding default value columns:This ensures the ID column is included when
KeepIdentity
is specified.The text was updated successfully, but these errors were encountered: