EntityFramework-Extensions
EntityFramework-Extensions copied to clipboard
Postgres + NodaTime + string[] not supported
Description
I have a project using EFCore 3.1 with relevant Postgres / NodaTime packages installed. I have an entity with a property of type Instant
. I cannot use BulkInsert as it throws an exception: "Oops! Unsupported types".
var options = new DbContextOptionsBuilder<DomainDbContext>()
.UseNpgsql(connectionString, o => o.UseNodaTime())
.UseLoggerFactory(loggerFactory)
.Options;
var context = new DomainDbContext(options);
context.MyEntity.BulkInsert(...);
Exception
System.Exception: An error occured while retrieving the InformationSchemaTable information. See the inner exception for details.
---> System.Exception: Oops! Unsupported types : ARRAY _text
---> System.Exception: Oops! Unsupported types : nodatime.instant
at .( , String[] )
--- End of inner exception stack trace ---
at .( , Exception , String[] )
at .( , String[] )
at .(Boolean , String[] )
at .()
at Z.BulkOperations.BulkOperation.()
--- End of inner exception stack trace ---
at Z.BulkOperations.BulkOperation.()
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkInsert()
at .BulkInsert[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping)
at .BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges)
at DbContextExtensions.BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options)
at DbContextExtensions.BulkInsert[T](DbContext this, IEnumerable`1 entities)
at DbSetExtensions.BulkInsert[T](DbSet`1 this, IEnumerable`1 entities)
Further technical details
- EF version: 3.1.21
- EF Extensions version: 3.13.1
- Database Provider: Npgsql.EntityFrameworkCore.PostgreSQL/3.1.18 Npgsql/4.1.9 Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime/3.1.18
Hello @Bouke ,
Thank you for reporting,
My developer will look at it.
Best Regards,
Jon
Apparently the nodatime in the exception is not relevant and is being mapped fine. The problem is the column with type text[]
:
public List<string> Tags { get; set; }
I believe a rather similar issue was also reported last december (#452), the OP closed the issue but the underlying issue hasn't been resolved it seems.
In #427 you've written the following:
We either support NodaTime or ARRAY for a specific table, but we didn't support both at the same time. Exactly as you initially said in your first post.
This is not a feasible solution to us as we need to use both.
Thank you for the additional information,
I will discuss some solutions that could allow supporting both, but it will probably require a configuration on your side as we cannot support both by default.
Just to make sure, the previous post about the issue #452 is no longer relevant with your last message about supporting both?
I'm disappointed to hear that it cannot be made to 'just work' and requires additional configuration on my end.
I have the exact same issue.
@JonathanMagnan Do you have any update regarding this?
@JonathanMagnan any update on this?
Hello All,
Sorry for the very long waiting.
The v7.21.0 has been released.
The combination of both should now work correctly. In this case, some additional SQL will be executed as both types cannot be retrieved the same way, but this SQL is only executed once (the model is cached).
If one of you has the chance to test it, let us know if that's now working with the latest version.
Best Regards,
Jon
The error that I had on 3.13.1 was this:
System.Exception: An error occured while retrieving the InformationSchemaTable information. See the inner exception for details.
---> System.Exception: Oops! Unsupported types : ARRAY _text
---> System.Exception: Oops! Unsupported types : nodatime.instant
at .( , String[] )
--- End of inner exception stack trace ---
at .( , Exception , String[] )
at .( , String[] )
at .(Boolean , String[] )
at .()
at Z.BulkOperations.BulkOperation.()
--- End of inner exception stack trace ---
at Z.BulkOperations.BulkOperation.()
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkInsert()
at .BulkInsert[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping)
at .BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges)
at .(DbContext this, List`1 , Action`1 )
at .(DbContext this, StateManager , IReadOnlyList`1 , Action`1 )
at .(DbContext this, StateManager , IReadOnlyList`1 , Action`1 )
at .(DbContext this, Action`1 , DbContext )
With 3.21.3 I'm now getting this:
System.Exception: An error occured while resolving mapping by name. See the inner exception for details
---> System.Exception: Missing Column : StringArrayProperty
On entity : Entity
On Table : "public"."Entity"
at Z.BulkOperations.BulkOperation.(String , Boolean , Boolean , Boolean )
at Z.BulkOperations.BulkOperation.()
--- End of inner exception stack trace ---
at Z.BulkOperations.BulkOperation.()
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkInsert()
at .BulkInsert[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping)
at .BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges)
at .(DbContext this, List`1 , Action`1 )
at .(DbContext this, StateManager , IReadOnlyList`1 , Action`1 )
at .(DbContext this, StateManager , IReadOnlyList`1 , Action`1 )
at .(DbContext this, Action`1 , DbContext )
Using db.SaveChanges()
works fine.
Hello Bouke,
Could you let us know what look your database table?
Normally this error means that the column name StringArrayProperty
doesn't exist in the database.
Could you give us your entity as well? and let us know more what is this StringArrayProperty
. Perhaps that is something our library should have ignored?
(You can hide everything sensitive not related to this property)
Best Regards,
Jon
Hello @Bouke,
Since our last conversation, we haven't heard from you.
Let us know if you need further assistance.
Best regards,
Jon
Hello again,
A simple reminder that we are here to assist you.
Don't hesitate to contact us if you need more information.
Best regards,
Jon