{"record":{"id":"cfce8dea8fbd4e83","repo":"dotnet/efcore","slug":"executeupdate-is-being-used-over-type-structur","errorCode":null,"errorMessage":"'ExecuteUpdate' is being used over type '{structuralType}' which is mapped to JSON; 'ExecuteUpdate' on JSON is not supported.","messagePattern":"'ExecuteUpdate' is being used over type '(.+?)' which is mapped to JSON; 'ExecuteUpdate' on JSON is not supported\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs","lineNumber":361,"sourceCode":"                    translatedSetters.Add(new ColumnValueSetter(column, translatedValue));\n                    break;\n                }\n\n                // A table-split complex type is being assigned a new value.\n                // Generate setters for each of the columns mapped to the comlex type.\n                case StructuralTypeShaperExpression\n                {\n                    StructuralType: IComplexType complexType,\n                    ValueBufferExpression: StructuralTypeProjectionExpression\n                } shaper:\n                {\n                    Check.DebugAssert(\n                        targetProperty is IComplexProperty complexProperty && complexProperty.ComplexType == complexType,\n                        \"PropertyBase should be a complex property referring to the correct complex type\");\n\n                    if (complexType.IsMappedToJson())\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.ExecuteUpdateOverJsonIsNotSupported(complexType.DisplayName()));\n                    }\n\n                    var translatedValue = TranslateSetterValueSelector(source, valueSelector, shaper.Type);\n                    ProcessComplexType(shaper, translatedValue);\n\n                    break;\n                }\n\n                case JsonScalarExpression { Json: ColumnExpression jsonColumn } jsonScalar:\n                {\n                    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);","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs#L343-L379","documentation":"Thrown when the SetProperty target resolves to a StructuralTypeShaperExpression whose ComplexType is mapped to JSON. EF Core cannot generate an ExecuteUpdate over a complex type that lives inside a JSON column (the JSON column is opaque to the relational update pipeline at this level).","triggerScenarios":"A complex property configured with ToJson (complex-JSON) and ExecuteUpdate targeting one of its scalar members. The source fires inside the StructuralTypeShaperExpression/IComplexType case of the setter switch when complexType.IsMappedToJson() is true.","commonSituations":"Using the newer complex-JSON mapping and attempting bulk updates; mixing complex types with JSON columns.","solutions":["Map the complex type to regular columns (ComplexProperty without ToJson) if you need ExecuteUpdate on its members.","Update the JSON-mapped complex type via load-modify-SaveChanges instead of ExecuteUpdate.","Move the updatable scalar out of the JSON complex type into the owning entity."],"exampleFix":"// before\nmodelBuilder.Entity<Root>().ComplexProperty(r => r.Address, b => b.ToJson(\"addr\"));\nawait ctx.Set<Root>().ExecuteUpdateAsync(s => s.SetProperty(r => r.Address.City, \"x\"));\n// after\nmodelBuilder.Entity<Root>().ComplexProperty(r => r.Address);\nawait ctx.Set<Root>().ExecuteUpdateAsync(s => s.SetProperty(r => r.Address.City, \"x\"));","handlingStrategy":"validation","validationCode":"// Detect JSON-mapped complex types before ExecuteUpdate.\nforeach (var ct in ctx.Model.GetEntityTypes().SelectMany(e => e.GetComplexProperties()))\nif (ct.ComplexType.IsMappedToJson())\n    logger.LogWarning(\"Complex type {Name} is JSON-mapped; ExecuteUpdate unsupported.\", ct.Name);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not call ToJson on complex properties that must support ExecuteUpdate.","Document which complex types are JSON vs column-mapped.","Use load-modify-SaveChanges for JSON complex types."],"tags":["efcore","executeupdate","complex-types","owned-json","query-translation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}