{"record":{"id":"9d6aaf49b5f8ba13","repo":"dotnet/efcore","slug":"executeupdate-cannot-currently-set-a-property-in","errorCode":null,"errorMessage":"'ExecuteUpdate' cannot currently set a property in a JSON column to a regular, non-JSON column; see https://github.com/dotnet/efcore/issues/36688.","messagePattern":"'ExecuteUpdate' cannot currently set a property in a JSON column to a regular, non-JSON column; see https://github\\.com/dotnet/efcore/issues/36688\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs","lineNumber":391,"sourceCode":"                    var typeMapping = jsonScalar.TypeMapping;\n                    Check.DebugAssert(typeMapping is not null);\n\n                    // We should never see a JsonScalarExpression without a path - that means we're mapping a JSON scalar directly to a relational column.\n                    // This is in theory possible (e.g. map a DateTime to a 'json' column with a single string timestamp representation inside, instead of to\n                    // SQL Server datetime2), but contrived and unsupported.\n                    Check.DebugAssert(jsonScalar.Path.Count > 0);\n\n                    ProcessColumn(jsonColumn, targetProperty);\n\n                    var translatedValue = TranslateScalarSetterValueSelector(source, valueSelector, jsonScalar.Type, typeMapping);\n\n                    // We now have the relational scalar expression for the value; but we need the JSON representation to pass to the provider's JSON modification\n                    // function (e.g. SQL Server JSON_MODIFY()).\n                    // For example, for a DateTime we'd have e.g. a SqlConstantExpression containing a DateTime instance, but we need a string containing\n                    // the JSON-encoded ISO8601 representation.\n                    if (!TrySerializeScalarToJson(jsonScalar, translatedValue, out var jsonValue))\n                    {\n                        throw new InvalidOperationException(\n                            translatedValue is ColumnExpression\n                                ? RelationalStrings.ExecuteUpdateCannotSetJsonPropertyToNonJsonColumn\n                                : RelationalStrings.ExecuteUpdateCannotSetJsonPropertyToArbitraryExpression);\n                    }\n\n                    // We now have a serialized JSON value (number, string or bool) - generate a setter for it.\n                    GenerateJsonPartialUpdateSetterWrapper(jsonScalar, jsonColumn, jsonValue);\n                    continue;\n                }\n\n                case StructuralTypeShaperExpression { ValueBufferExpression: JsonQueryExpression jsonQuery }:\n                    ProcessStructuralJsonSetter(jsonQuery);\n                    continue;\n\n                case CollectionResultExpression { QueryExpression: JsonQueryExpression jsonQuery }:\n                    ProcessStructuralJsonSetter(jsonQuery);\n                    continue;\n","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs#L373-L409","documentation":"Thrown inside the JsonScalarExpression case when TrySerializeScalarToJson fails and the value being assigned is a ColumnExpression. EF Core cannot set a JSON column's nested property to the value of a different, non-JSON column — the JSON modification functions only accept JSON-serialized scalars. Tracked by issue #36688.","triggerScenarios":"ExecuteUpdate with SetProperty pointing at a JSON scalar path and a value selector that projects a column from another table: SetProperty(e => e.JsonConfig.SomeFlag, e => e.OtherEntity.SomeFlag). The Sqlite tests (SqliteMiscellaneousTypeTest, SqliteTemporalTypeTest) assert this message.","commonSituations":"Trying to copy a value from a relational column into a JSON path in one ExecuteUpdate; cross-column assignments involving JSON.","solutions":["Split the operation: read the source value first, then ExecuteUpdate with a parameter/constant serialized into the JSON path.","Restructure so the JSON property is updated from a constant or parameter only (supported paths).","Track #36688 for future support of column-to-JSON assignments."],"exampleFix":"// before\nawait ctx.Set<Root>().ExecuteUpdateAsync(s =>\n    s.SetProperty(r => r.Config.Enabled, r => r.TmpFlag));\n// after\nvar flag = await ctx.Set<Root>().Select(r => r.TmpFlag).FirstAsync();\nawait ctx.Set<Root>().ExecuteUpdateAsync(s =>\n    s.SetProperty(r => r.Config.Enabled, flag));","handlingStrategy":"validation","validationCode":"// Detect column-source value selectors into JSON paths.\n// Heuristic: if the value selector references a property of a different entity/table than the JSON owner, read it first.\nvar src = await ctx.Set<Root>().Select(r => r.TmpFlag).FirstAsync();\nawait ctx.Set<Root>().ExecuteUpdateAsync(s => s.SetProperty(r => r.Config.Enabled, src));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reference another entity's column inside a JSON-path value selector.","Read the source value client-side and pass it as a parameter.","Track issue #36688 for native support."],"tags":["efcore","executeupdate","owned-json","query-translation","sqlite"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}