-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Trying to save a non-scalar nested JSON collection (List<List<X>>) saves incorrect data #33913
Comments
Notes following team discussion:
Bottom line: we should blog this in validation if it is done by convention. Open question: what does "by convention" mean in this case? The code above is explicitly mapping the entity type
|
Note from design meeting: error, but make it suppressible. |
Hi @ajcvickers, I just saw today that the problem has been "fixed", but a version hasn't been released yet, when is the release of the version containing this fix scheduled for release? I saw the code of the pull and added the exception "AccidentalEntityType" which says
I don't understand if my problem is not resolved or something else, with the new version the
So as you say in this #33913 (comment) the correct way to instantiate this field would be using an OwnsMany, even though in .NET 6 the |
Unable to create a 'DbContext' of type ''. The exception 'Owned entity type 'JsonbField' is mapped to table 'public.JsonbField' and contains JSON columns. This is currently not supported. All owned types containing a JSON column must be mapped to a JSON column themselves.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 OwnsMany throws an error, or maybe I'm not mapping the column well, these are the changes I made: Models
Configuration
I also tried adding the
|
Hi @ajcvickers, I understood this, but if you see my example above #33913 (comment), you can't even do a FK Relation (OwnsMany). Please take a look at the table structure I had thought of. Maybe it's wrong and it can be structured in another way, because the error is "All owned types containing a JSON column must be mapped to a JSON column themselves", and I don't think it has anything to do with List<List>. In this comment #33913 (comment), you suggest:
|
In the below, when saving
List<List<MyEntity>>
, SaveChanges() sends:@p0='[{"Capacity":2},{"Capacity":2}]'
, which seems to be the ToString() representation of the nested List.Assuming
List<List<T>>
is an unsupported scenario, we should catch this in model validation.Reported by @zN3utr4l in npgsql/efcore.pg#3172
The text was updated successfully, but these errors were encountered: