{"record":{"id":"f092fa25cecfe9a4","repo":"dotnet/efcore","slug":"identifier-without-symbol-identifiername","errorCode":null,"errorMessage":"Identifier without symbol: {identifierName}","messagePattern":"Identifier without symbol: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":422,"sourceCode":"\n        var symbol = _semanticModel.GetSymbolInfo(identifierName).Symbol;\n\n        ITypeSymbol typeSymbol;\n        switch (symbol)\n        {\n            case INamedTypeSymbol s:\n                return Constant(ResolveType(s));\n            case ILocalSymbol s:\n                typeSymbol = s.Type;\n                break;\n            case IFieldSymbol s:\n                typeSymbol = s.Type;\n                break;\n            case IPropertySymbol s:\n                typeSymbol = s.Type;\n                break;\n            case null:\n                throw new InvalidOperationException($\"Identifier without symbol: {identifierName}\");\n            default:\n                throw new UnreachableException($\"IdentifierName of type {symbol.GetType().Name}: {identifierName}\");\n        }\n\n        // TODO: Separate out EF Core-specific logic (EF Core would extend this visitor)\n        if (typeSymbol.Name.Contains(\"DbSet\"))\n        {\n            throw new NotImplementedException(\"DbSet local symbol\");\n        }\n\n        // We have an identifier which isn't in our parameters stack.\n\n        // First, if the identifier type is the user's DbContext type (e.g. DbContext local variable, or field/property),\n        // return a constant over that.\n        if (typeSymbol.Equals(_userDbContextSymbol, SymbolEqualityComparer.Default))\n        {\n            return Constant(_userDbContext);\n        }","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L404-L440","documentation":"`VisitIdentifierName` calls `GetSymbolInfo(identifierName).Symbol`; the `case null:` arm throws `InvalidOperationException` when Roslyn cannot bind the identifier to any symbol. That means the name is unresolvable in the current semantic model (undefined, or referencing something outside the compilation's references).","triggerScenarios":"Translating a query whose lambda references an identifier that the `SemanticModel` cannot resolve — a type/member from an unreferenced assembly, or a name that genuinely does not exist.","commonSituations":"Missing using-directives at the syntax-tree level, missing metadata references in the compilation, or stale `SemanticModel` from a different compilation.","solutions":["Add the assembly/reference that defines the identifier.","Ensure the tree carries the right `using` directives and is in the same compilation as the `SemanticModel`.","Replace the unresolved identifier with a resolvable equivalent."],"exampleFix":"// before\nvar q = ctx.Items.Where(i => Helper.Unresolved(i));   // Helper not referenced\n// after\n// add MetadataReference to Helper's assembly, then:\nvar q = ctx.Items.Where(i => Helper.Unresolved(i));","handlingStrategy":"validation","validationCode":"// Confirm every identifier in the query binds to a symbol before translating.\nvar unresolved = node.DescendantNodes().OfType<IdentifierNameSyntax>()\n    .FirstOrDefault(id => semanticModel.GetSymbolInfo(id).Symbol is null);\nif (unresolved is not null)\n    throw new InvalidOperationException(\n        $\"Identifier '{unresolved.Identifier.Text}' is unbound. Add the required references/usings.\");\n\ntranslator.Translate(node, semanticModel);","typeGuard":null,"tryCatchPattern":"try { translator.Translate(node, semanticModel); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Identifier without symbol:\"))\n{ /* add missing reference/using and rebuild the SemanticModel */ }","preventionTips":["Make sure the tree has the right `using` directives and is in the referenced compilation.","Reference all assemblies the query touches.","Validate identifiers bind before translating (cheap `GetSymbolInfo` check)."],"tags":["ef-core","precompiled-queries","roslyn","type-resolution","binding"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}