-
Notifications
You must be signed in to change notification settings - Fork 225
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
ExecuteUpdate
on Json properties fails.
#3348
Comments
@onionhammer I can't really look into issues in UpdateBatchAsync() since that's not part of EF or the PostgreSQL provider - it's a 3rd-party extension. |
@roji sorry, that's my own helper wrapper of Is throwing, even though |
UpdateBatchAsync
on Json properties fails.ExecuteUpdate
on Json properties fails.
I'm still not sure exactly what you're reporting, because you're posting snippets; please always submit a minimal, runnable code sample (e.g. a console program), otherwise it's hard to understand what you're trying to achieve. Specifically, you seem to be saying that if you do |
@roji Sorry I wasn't clear enough in the initial thread, I'll be less terse here: Both code snippets below result in a "JSONB" column in the actual underlying database, but only the first example allows you to reassign the property (which goes into the JSONB column in the database) Example 1: Allows
|
Thanks for the additional detail - that all makes sense. The first mapping style is the "legacy", Npgsql-specific jsonb POCO mapping, whereas the second is the more general EF owned entity-based ToJson() method. It indeed makes sense that doing ExecuteUpdate() on the root of a ToJson()-mapped JSON column doesn't work - this is a general EF limitation rather than something Npgsql-specific. dotnet/efcore#28766 tracks allowing changing properties inside a mapped JSON document (so partial update, rather than replacing the entire document; not quite what you want). dotnet/efcore#32719 more more or less tracks what you want: it's primarily concerned with non-owned entity types in ExecuteUpdate() (so entities mapped to a different table with a foreign key); but there's some analysis at the bottom around owned entities. More generally, the direction in EF 10 is going to be to allow mapping JSON columns via complex types, instead of the current owned entity approach (which has many problems). EF 8 already supports using complex types for non-JSON scenarios (table splitting, i.e. map some columns of the table to the complex type), and dotnet/efcore#32058 also added support for including such non-JSON complex types in ExecuteUpdate(). I hope that as part of this work, it will also be possible to update JSON-mapped complex types, so you'll have to wait until that's done (in the meantime, you can use SQL to express your UPDATE). I'll go ahead and close this as an EF-side issue - let me know if that all makes sense. |
Duplicate of dotnet/efcore#32719 |
Makes sense, thanks @roji ! |
Configure model builder as follows:
Execute an update on the the property in question
Fails with:
Succeeds if the configuration changes:
The text was updated successfully, but these errors were encountered: