dotnet/efcore · error · InvalidOperationException
Unable to bind '{memberType}.{member}' to an entity projecti
Error message
Unable to bind '{memberType}.{member}' to an entity projection of '{entityType}'. What it means
Thrown by JsonQueryExpression.BindProperty when the given IProperty's declaring type is not compatible with the JSON query expression's StructuralType. The property must belong to (or be a base of) the structural type that the JSON query expression represents; otherwise EF cannot locate it within the JSON document structure.
Source
Thrown at src/EFCore.Relational/Query/JsonQueryExpression.cs:131
[EntityFrameworkInternal]
public virtual IReadOnlyDictionary<IProperty, ColumnExpression>? KeyPropertyMap { get; }
/// <inheritdoc />
public override ExpressionType NodeType
=> ExpressionType.Extension;
/// <inheritdoc />
public override Type Type { get; }
/// <summary>
/// Binds a property with this JSON query expression to get the SQL representation.
/// </summary>
public virtual SqlExpression BindProperty(IProperty property)
{
if (!StructuralType.IsAssignableFrom(property.DeclaringType)
&& !property.DeclaringType.IsAssignableFrom(StructuralType))
{
throw new InvalidOperationException(
RelationalStrings.UnableToBindMemberToEntityProjection("property", property.Name, StructuralType.DisplayName()));
}
if (KeyPropertyMap?.TryGetValue(property, out var match) == true)
{
return match;
}
var element = GetJsonElement(property);
return new JsonScalarExpression(
JsonColumn,
[.. Path, new PathSegment(element.PropertyName!)],
property.ClrType.UnwrapNullableType(),
element.StoreTypeMapping!,
IsNullable || property.IsNullable);
}
View on GitHub (pinned to 3a2006ef56)
Solutions
- Verify your JSON mapping (ToJson) is applied to the correct owned entity types and that properties are accessed through the correct navigation chain.
- Ensure inheritance hierarchies with JSON columns are configured consistently across all mapped types.
- If the property belongs to a different entity, adjust the LINQ query to access it through the correct path.
- File a bug at https://github.com/dotnet/efcore with the JSON mapping configuration and query that triggers this.
Example fix
// before — accessing a property from wrong entity on a JSON query
// Customer.Settings is JSON-mapped; trying to bind Order.Total through Customer.Settings
var query = context.Customers
.Where(c => c.Settings.SomeProperty == true); // SomeProperty on wrong type
// after — ensure the property exists on the JSON-mapped owned type
var query = context.Customers
.Where(c => c.Settings.ValidProperty == true); Defensive patterns
Strategy: try-catch
Try / catch
try
{
var result = await context.Customers
.Where(c => c.Settings.SomeValue == 42)
.ToListAsync();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Unable to bind") && ex.Message.Contains("entity projection"))
{
logger.LogError(ex, "JSON property binding failed — verify the property belongs to the JSON-mapped type");
throw;
} Prevention
- Ensure LINQ queries only access properties through the correct JSON-mapped navigation chain.
- Keep JSON entity type hierarchies simple and well-tested.
- Write integration tests for all JSON property access patterns used in the application.
- Verify ToJson mapping covers the properties you query against.
When it happens
Trigger: Internal query pipeline calls BindProperty with an IProperty that belongs to a different entity/complex type than the one the JsonQueryExpression was constructed for. This happens when JSON path resolution logic attempts to bind a property from an unrelated or sibling type into a JSON column.
Common situations: Complex JSON-mapped entity hierarchies with inheritance where the wrong derived type's property is bound. TPT/TPC + JSON mapping interaction where multiple tables each carry the JSON column but the property's declaring type doesn't match. An EF Core internal bug in JSON query expression construction during translation.
Related errors
- The JSON query expression for '{structuralType}' has no unde
- No JSON element mapping was found for '{structuralType}.{nam
- Both properties '{property1}' and '{property2}' on entity ty
- The JSON property name should only be configured on nested o
- The property '{property}' on type '{type}' is mapped to a JS
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/0ba9cef44b6d0191.
Report an issue: GitHub.