EFCore.BulkExtensions icon indicating copy to clipboard operation
EFCore.BulkExtensions copied to clipboard

PostgreSQL BulkInsertAsync throws exception missing datetime type

Open Temppus opened this issue 3 years ago • 1 comments

I am using EFCore.BulkExtensions 6.5.0 with EF core 6.0.5 and when trying to bulk insert entities to PostgreSQL database I am getting.

 Message: 
System.ArgumentException : A PostgreSQL type with the name datetime was not found in the database

  Stack Trace: 
NpgsqlDatabaseInfo.GetPostgresTypeByName(String pgName)
ConnectorTypeMapper.ResolveByDataTypeName(String typeName, Boolean throwOnError)
ConnectorTypeMapper.ResolveByDataTypeName(String typeName)
NpgsqlParameter.ResolveHandler(ConnectorTypeMapper typeMapper)
NpgsqlBinaryImporter.Write[T](T value, NpgsqlParameter param, Boolean async, CancellationToken cancellationToken)
PostgreSqlAdapter.InsertAsync[T](DbContext context, IList1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken)
PostgreSqlAdapter.InsertAsync[T](DbContext context, IList1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken)
PostgreSqlAdapter.InsertAsync[T](DbContext context, Type type, IList1 entities, TableInfo tableInfo, Action1 progress, CancellationToken cancellationToken)
SqlBulkOperation.InsertAsync[T](DbContext context, Type type, IList1 entities, TableInfo tableInfo, Action1 progress, CancellationToken cancellationToken)
DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IList1 entities, OperationType operationType, BulkConfig bulkConfig, Action1 progress, CancellationToken cancellationToken)

I am aware of PostgreSQL breaking change about datetimes but I am using only UTC datetimes. Closest I could find was https://stackoverflow.com/questions/71474313/npgsql-ef-6-timestamp-fails-when-using-executesqlinterpolatedasync.

Is there something I am doing wrong or I am not aware of ? Thanks.

Temppus avatar Jun 23 '22 12:06 Temppus

Can you write test example where the issue would be reproducible. Existing test InsertTestPostgreSql has class Item with property TimeUpdated, and it passes regularly.

borisdj avatar Jul 06 '22 22:07 borisdj