{"record":{"id":"8accd77c51c3887d","repo":"dotnet/efcore","slug":"translation-of-expression-failed-either-the-q","errorCode":null,"errorMessage":"Translation of '{expression}' failed. Either the query source is not an entity type, or the specified property does not exist on the entity type.","messagePattern":"Translation of '(.+?)' failed\\. Either the query source is not an entity type, or the specified property does not exist on the entity type\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs","lineNumber":656,"sourceCode":"    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)\n    {\n        if (methodCallExpression.Method.IsGenericMethod\n            && methodCallExpression.Method.GetGenericMethodDefinition() == ExpressionExtensions.ValueBufferTryReadValueMethod)\n        {\n            return methodCallExpression;\n        }\n\n        // EF.Property case\n        if (methodCallExpression.TryGetEFPropertyArguments(out var source, out var propertyName))\n        {\n            return TryBindMember(Visit(source), MemberIdentity.Create(propertyName), methodCallExpression.Type)\n                ?? throw new InvalidOperationException(CoreStrings.QueryUnableToTranslateEFProperty(methodCallExpression.Print()));\n        }\n\n        // EF Indexer property\n        if (methodCallExpression.TryGetIndexerArguments(_model, out source, out propertyName))\n        {\n            return TryBindMember(Visit(source), MemberIdentity.Create(propertyName), methodCallExpression.Type)\n                ?? QueryCompilationContext.NotTranslatedExpression;\n        }\n\n        // Subquery case\n        var subqueryTranslation = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression);\n        if (subqueryTranslation != null)\n        {\n            var subquery = (InMemoryQueryExpression)subqueryTranslation.QueryExpression;\n            if (subqueryTranslation.ResultCardinality == ResultCardinality.Enumerable)\n            {\n                return QueryCompilationContext.NotTranslatedExpression;\n            }","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs#L638-L674","documentation":"Thrown when EF.Property(source, \"Name\") cannot be bound because the source is not an entity/struct type or the named property does not exist on it. TryBindMember returns null, so the translator throws QueryUnableToTranslateEFProperty to make the missing mapping explicit rather than emitting null.","triggerScenarios":"An expression tree contains EF.Property(obj, \"Foo\") where obj does not resolve to a known entity, or \"Foo\" is not a mapped property/shadow property/indexer on that entity's model.","commonSituations":"Referencing a property by a misspelled name, a renamed column, or a property that was removed from the model. Calling EF.Property on a DTO or anonymous projection rather than an entity. Accessing a navigation that was configured as not-mapped.","solutions":["Verify the property name spelling matches a mapped property on the entity type.","Ensure the source expression resolves to a tracked entity type, not a projection or DTO.","If the value is a shadow property, confirm it is configured in the model (e.g. via .Property<string>(\"Foo\")).","Replace EF.Property with a normal member access where possible, since EF translates mapped properties directly."],"exampleFix":"// before\nvar q = db.Users.Select(u => EF.Property<string>(u, \"Nmae\"));\n// after\nvar q = db.Users.Select(u => u.Name);","handlingStrategy":"validation","validationCode":"// Validate the EF.Property target before building the query\nvar et = dbContext.Model.FindEntityType(typeof(User));\nif (et?.FindProperty(\"Name\") is null)\n    throw new InvalidOperationException(\"Property 'Name' is not mapped on User\");","typeGuard":"static bool HasMappedProperty(IModel model, Type clrType, string name)\n    => model.FindEntityType(clrType)?.FindProperty(name) is not null;","tryCatchPattern":null,"preventionTips":["Prefer direct member access over EF.Property when possible.","Spell property names exactly as mapped; consider nameof(EntityType.Property).","Confirm shadow properties are declared in the model before referencing them."],"tags":["in-memory","query","translation","ef-property"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}