Giorgi / EntityFramework.Exceptions

Strongly typed exceptions for Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql.
https://giorgi.dev/entity-framework/introducing-entityframework-exceptions/
Other
1.44k stars 68 forks source link

InvalidCastException when saving entities with Pgvector.Vector #73

Closed foxminchan closed 4 months ago

foxminchan commented 4 months ago

When attempting to save an entity that contains a property of type Pgvector.Vector using EntityFramework.Exceptions.PostgreSQL, an InvalidCastException is thrown with the message "Writing values of 'Pgvector.Vector' is not supported for parameters having no NpgsqlDbType or DataTypeName. Try setting one of these values to the expected database type." This exception occurs during the DbUpdateException when the entity changes are being saved.

The issue seems to be specific to the use of EntityFramework.Exceptions.PostgreSQL, as the same operation works without this package. This suggests a potential incompatibility or misconfiguration between the package and the handling of Pgvector.Vector types.

image

Giorgi commented 4 months ago

What happens if you add the package but don't call UseExceptionProcessor? The code in this library runs only in response to an exception and doesn't change how data is saved to the database.

foxminchan commented 4 months ago

Apologies for the confusion. I retried the steps in a different project (To-do project) and it worked fine. However, in the project I'm currently working on, I still haven't been able to identify the factors causing this error. Therefore, I will temporarily close this issue and gather enough resources to discuss it later.