-
-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PostgreSQL: Failes to BulkInsert
entity with JSONb column configured with recommended Owned Entity Mapping
#1432
Comments
In my commit I did a small hackfix to solve the issue for me. This code probably only works in my case for It looks like the var table = context.Model.GetRelationalModel().Tables.First(_ => _.Name == TableName);
string column = table.FindColumn(columnName)!;
string columnType = column.StoreType;
string sqlValue = column.StoreTypeMapping.GenerateProviderValueSqlLiteral(value).Trim('\''); ColumnName can be obtained using: INavigation jsonProperty = ..
string columnName = (string) jsonProperty.TargetEntityType.GetAnnotation("Relational:ContainerColumnName").Value!; I won't make a pull request with my commit because it probably breaks other functionality. Best regards |
@borisdj Any plans of an official fix for this (not requesting/pressuring, I'm already very grateful for this library, just curious if it was on the radar)? I'm not yet knowledgeable enough to confidently fix it myself or understand the potential side effects of the patch above. Just checking because if there's no fix planned I'll just refactor my model to not use owned jsonb columns for now. Thanks! |
Will try to work it out in the following days. |
PostgreSQL: Failes to
BulkInsert
entity with JSONb column configured with recommendedOwned Entity Mapping
.It looks like EFCore.BulkExtensions handles the Jsonb columns like a relation navigation property but it is configured as
Owned Entity
with conversion to JSON.The property is configured with:
builder.OwnsOne(_ => _.Metadata, _ => _.ToJson());
docs:npgsql.orgThis code throws the exception:
Exception: (Metadata is a Jsonb column not a relation)
Entity with configured Jsonb column:
EF Context Setup for PostgreSQL
The text was updated successfully, but these errors were encountered: