-
-
Notifications
You must be signed in to change notification settings - Fork 630
Open
Description
If I have the following table:
CREATE TABLE public.sample_table (
sample_id UUID NOT NULL PRIMARY KEY,
list_of_codes CHAR(4)[] NULL
);with the following c# table definition:
[Table("sample_table", Schema = "public")]
public partial class SampleTable
{
[Key]
[Column("sample_id")]
public Guid SampleId { get; set; }
[Column("list_of_codes", TypeName = "character(4)[]")]
public List<string>? ListOfCodes { get; set; }
}running this:
await MyDbContext.BulkInsertOrUpdateAsync(
[
new SampleTable { SampleId = Guid.NewGuid(), ListOfCodes = ["1234"] },
new SampleTable { SampleId = Guid.NewGuid(), ListOfCodes = ["1234"] }
],
cancellationToken: CancellationToken);results in this error:
System.InvalidCastException: Writing values of 'System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' is not supported for parameters having DataTypeName 'character'.
at Npgsql.Internal.AdoSerializerHelpers.<GetTypeInfoForWriting>g__ThrowWritingNotSupported|1_0(Type type, PgSerializerOptions options, Nullable`1 pgTypeId, Nullable`1 npgsqlDbType, Exception inner)
at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForWriting(Type type, Nullable`1 pgTypeId, PgSerializerOptions options, Nullable`1 npgsqlDbType)
at Npgsql.NpgsqlParameter.ResolveTypeInfo(PgSerializerOptions options)
at Npgsql.NpgsqlBinaryImporter.<Write>g__Core|26_0[T](Boolean async, T value, Nullable`1 npgsqlDbType, String dataTypeName, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, CancellationToken cancellationToken)
at EFCore.BulkExtensions.SqlBulkOperation.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, CancellationToken cancellationToken)
at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, CancellationToken cancellationToken)
The class was scaffolded, so I don't believe there are issues there: if I do a standard EFCore insert or update, those perform as expected.
versions:
EFCore.BulkExtensions.PostgreSql 9.0.1
Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels