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
System.Collections.Generic.KeyNotFoundException: The given key 'Id' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at EFCore.BulkExtensions.TableInfo.LoadData[T](DbContext context, Type type, IEnumerable`1 entities, Boolean loadOnlyPKColumn)
at EFCore.BulkExtensions.TableInfo.CreateInstance[T](DbContext context, Type type, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig)
at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, CancellationToken cancellationToken)
[...]
Enabling EnableShadowProperties and ShadowPropertyValue (to set the primary key on client side instead of relying on the SQL default value) do not change the outcome.
EDIT: I also trying adding config.PropertiesToExclude = ["Id"]; to no avail.
I tried debugging using Rider's decompiler and it seems that the exception is thrown in EFCore.BulkExtensions' TableInfo.cs at line 354 (link).
Looking at the code, it seems an edge case: GUID primary key + shadow property = exception. I could not figure out what dictionary the exception is talking about since allPropertiesExceptTimeStamp is an IEnumerable.
The text was updated successfully, but these errors were encountered:
I have a SQL Server table with a primary key which is mapped to EFCore as a shadow property:
I am calling
BulkInsertAsync
like this:It throws the following exception:
Enabling
EnableShadowProperties
andShadowPropertyValue
(to set the primary key on client side instead of relying on the SQL default value) do not change the outcome.EDIT: I also trying adding
config.PropertiesToExclude = ["Id"];
to no avail.I tried debugging using Rider's decompiler and it seems that the exception is thrown in EFCore.BulkExtensions' TableInfo.cs at line 354 (link).
Looking at the code, it seems an edge case: GUID primary key + shadow property = exception. I could not figure out what dictionary the exception is talking about since
allPropertiesExceptTimeStamp
is anIEnumerable
.The text was updated successfully, but these errors were encountered: