Skip to content

BulkInsert Exception using NpgSql and jsonb in .NET 8 #560

Open
@rabberbock

Description

@rabberbock

Description

Bulk Insert throws an exception when the entity has a jsonb column. The jsonb column mapping is set in OnModelCreating.

Exception

Exception message: The given key 'EntityType: BlogMetadata Owned' was not present in the dictionary.
Stack trace:    at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNotFoundException(TKey key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Z.EntityFramework.Extensions.PropertyZInfo.GetFlatternHierarchyPath(IEntityType entityType)
   at .[](BulkOperation`1 this, BulkOperationActionType , Boolean , Dictionary`2 , IEntityType , List`1 , HashSet`1 , Dictionary`2 )
   at .[](BulkOperation`1 this, IEntityType , BulkOperationActionType )
   at .[](BulkOperation`1 this, DbContext , IEntityType , IEnumerable`1 , BulkOperationActionType )
   at .BulkInsert[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping, Boolean isOptimized)
   at .[](DbContext , SavingSelector , Action`1 )
   at .[](DbContext ,  , BulkOperationActionType , Action`1 )
   at .BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges, Boolean isOptimized)
   at DbContextExtensions.BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options)
   at DbContextExtensions.`1.()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at DbContextExtensions.BulkInsertAsync[T](DbContext this, IEnumerable`1 entities, Action`1 options, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args) in C:\Users\rabbe\Projects\Samples\EFGetStarted\Program.cs:line 61

Fiddle or Project (Optional)

https://github.com/rabberbock/BulkInsertJsonb/tree/master

Further technical details

  • EF version: [EF Core v8.0.0]
  • EF Extensions version: [EFE Core v8.101.0]
  • Database Server version: [Postgres 14]
  • Database Provider version (NuGet): [Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0]

Thanks in advance with you help with this. Thanks!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions