{"record":{"id":"0f8b8a89a14794fb","repo":"dotnet/efcore","slug":"jsonelementmappingnotfound","errorCode":"JsonElementMappingNotFound","errorMessage":"No JSON element mapping was found for '{structuralType}.{name}' on column '{columnName}'.","messagePattern":"No JSON element mapping was found for '(.+?)\\.(.+?)' on column '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Query/JsonQueryExpression.cs","lineNumber":313,"sourceCode":"    /// <summary>\n    ///     Finds the <see cref=\"IRelationalJsonElement\" /> for the given property/navigation/complex property within the\n    ///     JSON column referenced by this expression by matching <see cref=\"JsonColumn\" />'s underlying\n    ///     <see cref=\"ColumnExpression.Column\" /> against <see cref=\"IRelationalJsonElement.ContainingColumn\" />. This\n    ///     disambiguates entity-splitting, TPT and TPC scenarios where the same property has multiple JSON element\n    ///     mappings — one per concrete table.\n    ///     <see cref=\"IRelationalJsonElement.PropertyName\" /> may be <see langword=\"null\" /> for shadow keys that have\n    ///     no JSON representation; callers iterating over <see cref=\"ITypeBase.GetProperties\" /> must handle that case\n    ///     and skip them.\n    /// </summary>\n    /// <param name=\"propertyBase\">The property, navigation or complex property to look up.</param>\n    /// <returns>The JSON element mapping for <paramref name=\"propertyBase\" />.</returns>\n    public virtual IRelationalJsonElement GetJsonElement(IPropertyBase propertyBase)\n    {\n        var column = JsonColumn.Column\n            ?? throw new InvalidOperationException(\n                RelationalStrings.JsonQueryExpressionWithoutUnderlyingColumn(StructuralType.DisplayName()));\n        return FindJsonElement(propertyBase)\n            ?? throw new InvalidOperationException(\n                RelationalStrings.JsonElementMappingNotFound(propertyBase.DeclaringType.DisplayName(), propertyBase.Name, column.Name));\n    }\n\n    /// <summary>\n    ///     Finds the <see cref=\"IRelationalJsonElement\" /> for the given property/navigation/complex property within the\n    ///     JSON column referenced by this expression by matching <see cref=\"JsonColumn\" />'s underlying\n    ///     <see cref=\"ColumnExpression.Column\" /> against <see cref=\"IRelationalJsonElement.ContainingColumn\" />, or returns\n    ///     <see langword=\"null\" /> if no such element exists (including when <see cref=\"JsonColumn\" /> has no underlying\n    ///     <see cref=\"ColumnExpression.Column\" />, e.g. for synthetic JSON expansions over OPENJSON / json_each, or for\n    ///     iterated properties such as shadow keys that have no JSON representation).\n    /// </summary>\n    /// <param name=\"propertyBase\">The property, navigation or complex property to look up.</param>\n    /// <returns>The JSON element mapping for <paramref name=\"propertyBase\" />, or <see langword=\"null\" /> if not found.</returns>\n    public virtual IRelationalJsonElement? FindJsonElement(IPropertyBase propertyBase)\n    {\n        var containingColumn = JsonColumn.Column;\n        if (containingColumn is null)\n        {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Query/JsonQueryExpression.cs#L295-L331","documentation":"Thrown by JsonQueryExpression.GetJsonElement (JsonQueryExpression.cs:313) when FindJsonElement returns null: no JSON element mapping for the given property/navigation/complex property exists on the column this expression references. EF resolves JSON paths via IRelationalJsonElement mappings matched to a specific column; if none matches (property has no JSON representation on that column), the path cannot be built and EF throws.","triggerScenarios":"Calling GetJsonElement for a property/navigation/complex property that has no JSON element mapping on the JsonQueryExpression's column. Happens in TPT/TPC/entity-splitting where a property has multiple JSON mappings but none on this column, or when querying a property that isn't part of the JSON document (e.g. a shadow key or a property mapped elsewhere).","commonSituations":"TPT/TPC with JSON-mapped owned types where the property maps to a different concrete table's column; querying a property that was removed from the JSON mapping; provider/model inconsistency after a migration; shadow keys that have no JSON representation being resolved.","solutions":["Ensure the property has a JSON element mapping on the column referenced by this JsonQueryExpression (check GetJsonElementMappings and ContainingColumn).","In TPT/TPC/splitting, make sure the query's JSON expression targets the concrete table whose column holds that property.","Skip properties with no JSON representation (shadow keys) using FindJsonElement before GetJsonElement.","Regenerate migrations / verify the model so every expected property has a mapping on the relevant column."],"exampleFix":"// before - GetJsonElement throws when no mapping exists for the property on this column\nvar element = jsonExpr.GetJsonElement(someProperty); // JsonElementMappingNotFound\n\n// after - probe first and handle the unmapped case\nvar element = jsonExpr.FindJsonElement(someProperty);\nif (element is null) {\n    // property has no JSON representation on this column; skip or handle (e.g. shadow key)\n    continue;\n}","handlingStrategy":"validation","validationCode":"// Probe with FindJsonElement and handle missing mappings gracefully.\nvar element = jsonExpr.FindJsonElement(prop);\nif (element is null) {\n    // property has no JSON mapping on this column; skip or handle\n    continue;\n}\n// use element.PropertyName ...","typeGuard":"bool HasJsonMappingOnColumn(IPropertyBase p, ColumnExpression c)\n    => p.GetJsonElementMappings().Any(m => ReferenceEquals(m.Element.ContainingColumn, c));","tryCatchPattern":null,"preventionTips":["Use FindJsonElement before GetJsonElement to avoid throwing on unmapped properties.","In TPT/TPC/splitting, ensure the JSON expression targets the concrete table holding the property.","Skip shadow keys (no JSON representation) when iterating properties.","Keep migrations and JSON column mappings consistent across the model."],"tags":["ef-core","json","query-expression","column-mapping","provider"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}