dotnet/efcore · error · InvalidOperationException
MemberAccess: Couldn't find symbol for member: {memberAccess
Error message
MemberAccess: Couldn't find symbol for member: {memberAccess} What it means
VisitMemberAccessExpression throws InvalidOperationException when Roslyn cannot resolve a member access (a.B) to any symbol. The translator needs the member symbol to map it to a reflection PropertyInfo/FieldInfo.
Source
Thrown at src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs:772
/// </summary>
public override Expression VisitLiteralExpression(LiteralExpressionSyntax literal)
=> _semanticModel.GetTypeInfo(literal) is { ConvertedType: { } type }
? Constant(literal.Token.Value, ResolveType(type))
: Constant(literal.Token.Value);
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override Expression VisitMemberAccessExpression(MemberAccessExpressionSyntax memberAccess)
{
var expression = Visit(memberAccess.Expression);
if (_semanticModel.GetSymbolInfo(memberAccess).Symbol is not { } memberSymbol)
{
throw new InvalidOperationException($"MemberAccess: Couldn't find symbol for member: {memberAccess}");
}
var containingType = ResolveType(memberSymbol.ContainingType);
var memberInfo = memberSymbol switch
{
IPropertySymbol p => (MemberInfo?)containingType.GetProperty(p.Name),
IFieldSymbol f => containingType.GetField(f.Name),
INamedTypeSymbol t => containingType.GetNestedType(t.Name),
null => throw new InvalidOperationException($"MemberAccess: Couldn't find symbol for member: {memberAccess}"),
_ => throw new NotSupportedException($"MemberAccess: unsupported member symbol '{memberSymbol.GetType().Name}': {memberAccess}")
};
switch (memberInfo)
{
case Type nestedType:
return Constant(nestedType);
View on GitHub (pinned to dbf9771522)
Solutions
- Verify the member name and that the containing type is referenced by the precompilation
- Make sure the query compiles cleanly in the IDE before precompiling
- Remove dynamic member access; use strongly-typed variables
Example fix
// before (typo / unresolved) var q = ctx.Blogs.Where(b => b.Titel == "x"); // after var q = ctx.Blogs.Where(b => b.Title == "x");
Defensive patterns
Strategy: validation
Validate before calling
// Ensure the query is error-free in the IDE (Roslyn would otherwise fail to bind the member).
// Confirm the member exists and the containing type is referenced.
var pi = typeof(Entity).GetProperty(nameof(Entity.Title));
if (pi is null) { /* fix typo / add reference */ } Prevention
- Build the project with zero errors/warnings before precompiling queries
- Double-check property names for typos
- Reference every assembly whose types are accessed in the query
When it happens
Trigger: A member access where GetSymbolInfo(memberAccess).Symbol is null: a typo, a member on an error/unresolved type, dynamic member access, or a member that only exists in an unreferenced assembly.
Common situations: Misspelled property names; accessing members of types from namespaces/assemblies not referenced by the precompilation; accessing members of dynamic-typed expressions.
Related errors
- ArrayCreation: non-array type symbol: {implicitArrayCreation
- Could not find symbol for method invocation: {invocation}
- MemberAccess: couldn't find member '{memberSymbol.Name}': {m
- ObjectCreation: couldn't find IMethodSymbol for constructor:
- Could not find symbol for typeof() expression: {typeOf}
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/edfd8c6c669d6d4e.
Report an issue: GitHub.