{"record":{"id":"85cb46c8930dbac3","repo":"dotnet/efcore","slug":"memberaccess-couldn-t-find-member-membersymbol","errorCode":null,"errorMessage":"MemberAccess: couldn't find member '{memberSymbol.Name}': {memberAccess}","messagePattern":"MemberAccess: couldn't find member '(.+?)': (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":792,"sourceCode":"\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\n            case null:\n                throw new InvalidOperationException($\"MemberAccess: couldn't find member '{memberSymbol.Name}': {memberAccess}\");\n        }\n\n        // Enum field constant\n        if (containingType.IsEnum)\n        {\n            return Constant(Enum.Parse(containingType, memberInfo.Name), containingType);\n        }\n\n        // array.Length\n        return expression.Type.IsArray && memberInfo.Name == \"Length\"\n            ? expression.Type.GetArrayRank() != 1\n                ? throw new NotImplementedException(\"MemberAccess on multi-dimensional array\")\n                : (Expression)ArrayLength(expression)\n            : MakeMemberAccess(\n                expression is ConstantExpression { Value: Type } ? null : expression,\n                memberInfo);\n    }\n","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L774-L810","documentation":"The member symbol resolved via Roslyn, but reflection lookup (GetProperty/GetField/GetNestedType) on the containing type returned null. The member is visible to the compiler but not discoverable/accessible via reflection, so the translator cannot build the MemberExpression.","triggerScenarios":"Accessing an internal/private member across an assembly boundary without InternalsVisibleTo, an explicit interface implementation member, a compiler-generated backing member, or a member whose defining assembly version differs from what reflection loads.","commonSituations":"Internal properties on entities shared across projects; members present only in a newer/older assembly version than the runtime load; explicit interface implementation properties accessed without the interface.","solutions":["Make the member public","Add [InternalsVisibleTo] for the consuming assembly","Ensure the assembly version referenced at build time matches the runtime load","Avoid explicit-interface-only members in precompiled queries"],"exampleFix":"// before\ninternal string Secret { get; set; }\n// after\npublic string Secret { get; set; }","handlingStrategy":"validation","validationCode":"// Confirm the member is reflection-accessible from the consuming assembly.\nvar pi = typeof(Entity).GetProperty(\"InternalProp\", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);\nif (pi is null) { /* make public or add InternalsVisibleTo */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make members accessed in precompiled queries public, or grant InternalsVisibleTo","Avoid explicit-interface-only members in queries","Keep assembly versions consistent between build and runtime"],"tags":["efcore","precompiled-queries","reflection","member-resolution","csharp"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}