You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type mapping extension point for server-side (SQL) JSON serialization #36729
EF 10 introduced ExecuteUpdate support for JSON, which allows partially updating properties without JSON documents; this happens fully on the server-side, with no client-side JSON serialization (as in SaveChanges).
How exactly an arbitrary relational value is converted to JSON - in SQL - is a non-trivial thing that varies across databases:
In EF 10 for SQL Server, we're generating JSON_VALUE(JSON_OBJECT('v': <RELATIONAL VALUE>), '$.v')) to construct a JSON object (server-side) containing the relational value, and then extract it out as JSON.
However, geography and geometry are unsupported by JSON_OBJECT ("user-defined types"), and so we special-case them and use ST_AsText instead.
SQLite needs special handling to convert 1 and 0 to JSON true/false.
All this database-specific and type-specific logic currently lives in RelationalQueryableMethodTranslatingExpressionVisitorTrySerializeScalarToJson, overridden by each provider. However, we should consider moving that to a type mapping API instead. This would also allow for EF plugins to easily add their own logic, if necessary.
Activity
AndriySvyryd commentedon Sep 9, 2025
Related to #38036