EFCore.BulkExtensions
EFCore.BulkExtensions copied to clipboard
PostgreSQL BulkInsertAsync throws exception missing datetime type
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.
Can you write test example where the issue would be reproducible. Existing test InsertTestPostgreSql has class Item with property TimeUpdated, and it passes regularly.