{"record":{"id":"edfd8c6c669d6d4e","repo":"dotnet/efcore","slug":"memberaccess-couldn-t-find-symbol-for-member-me","errorCode":null,"errorMessage":"MemberAccess: Couldn't find symbol for member: {memberAccess}","messagePattern":"MemberAccess: Couldn't find symbol for member: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":772,"sourceCode":"    /// </summary>\n    public override Expression VisitLiteralExpression(LiteralExpressionSyntax literal)\n        => _semanticModel.GetTypeInfo(literal) is { ConvertedType: { } type }\n            ? Constant(literal.Token.Value, ResolveType(type))\n            : Constant(literal.Token.Value);\n\n    /// <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    public override Expression VisitMemberAccessExpression(MemberAccessExpressionSyntax memberAccess)\n    {\n        var expression = Visit(memberAccess.Expression);\n\n        if (_semanticModel.GetSymbolInfo(memberAccess).Symbol is not { } memberSymbol)\n        {\n            throw new InvalidOperationException($\"MemberAccess: Couldn't find symbol for member: {memberAccess}\");\n        }\n\n        var containingType = ResolveType(memberSymbol.ContainingType);\n        var memberInfo = memberSymbol switch\n        {\n            IPropertySymbol p => (MemberInfo?)containingType.GetProperty(p.Name),\n            IFieldSymbol f => containingType.GetField(f.Name),\n            INamedTypeSymbol t => containingType.GetNestedType(t.Name),\n\n            null => throw new InvalidOperationException($\"MemberAccess: Couldn't find symbol for member: {memberAccess}\"),\n            _ => throw new NotSupportedException($\"MemberAccess: unsupported member symbol '{memberSymbol.GetType().Name}': {memberAccess}\")\n        };\n\n        switch (memberInfo)\n        {\n            case Type nestedType:\n                return Constant(nestedType);\n","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L754-L790","documentation":"Thrown by VisitMemberAccessExpression when Roslyn's GetSymbolInfo on a member access expression returns a null Symbol. The translator cannot determine what property, field, or nested type is being accessed without the symbol, so it throws InvalidOperationException. This is distinct from [208] — here the symbol itself is missing; in [208] the symbol exists but reflection can't find the member.","triggerScenarios":"A precompiled query accesses a member (property, field, nested type) that Roslyn cannot resolve. Causes include: the member doesn't exist in the referenced compilation (compile error), the access is through an error type, the semantic model is stale/incomplete, or the member access is on a dynamic-typed expression.","commonSituations":"Accessing members on objects whose type is defined in a not-yet-compiled or circularly-referenced project; accessing members through `dynamic` typed variables; stale semantic model after code edits without recompilation; accessing members of anonymous types across assembly boundaries where type inference fails; conditional member access on compiler-generated backing fields.","solutions":["Ensure the project compiles cleanly before running precompilation — run dotnet build and fix all errors first.","If the member is on an external type, verify the containing assembly is referenced and passed to Load() via additionalAssembly.","Avoid dynamic-typed expressions inside precompiled queries — use strongly-typed variables.","If accessing members of anonymous types, keep the anonymous type usage within the same query scope where the compiler can infer the type."],"exampleFix":"// before — member access Roslyn can't resolve (dynamic or missing type)\nvar query = ctx.Blogs.Where(b => ((dynamic)b).UnknownProperty != null);\n\n// after — strongly typed\nvar query = ctx.Blogs.Where(b => b.Name != null);","handlingStrategy":"validation","validationCode":"// Before precompiling, verify all member accesses resolve to symbols\nvar unresolvedMembers = querySyntaxTree.DescendantNodes()\n    .OfType<MemberAccessExpressionSyntax>()\n    .Where(m => semanticModel.GetSymbolInfo(m).Symbol is null);\nif (unresolvedMembers.Any())\n    ReportError(\"Unresolved member access in precompiled query — check references and compile errors\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the project compiles with zero errors before precompilation.","Avoid dynamic-typed variables in precompiled queries.","Keep all assemblies referenced by the project available to the precompilation pipeline.","Avoid accessing members of anonymous types across method boundaries."],"tags":["precompiled-queries","roslyn","symbol-resolution","member-access","expression-tree"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}