dotnet/efcore · error · InvalidOperationException
Could not find type symbol for: {node}
Error message
Could not find type symbol for: {node} What it means
Thrown by ResolveType(SyntaxNode) when _semanticModel.GetTypeInfo(node).Type is null - Roslyn cannot determine the type of the syntax node. This is a semantic-analysis failure: the node has no resolvable type symbol. Part of EF Core's precompiled-query C#-to-LINQ translation.
Source
Thrown at src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs:1120
/// <summary>
/// Given a Roslyn type symbol, returns a .NET reflection <see cref="Type" />.
/// </summary>
/// <param name="typeSymbol">The type symbol to be translated.</param>
/// <returns>A .NET reflection <see cref="Type" /> that corresponds to <paramref name="typeSymbol" />.</returns>
/// <remarks>
/// 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.
/// </remarks>
public virtual Type TranslateType(ITypeSymbol typeSymbol)
=> ResolveType(typeSymbol);
private Type ResolveType(SyntaxNode node)
=> _semanticModel.GetTypeInfo(node).Type is { } typeSymbol
? ResolveType(typeSymbol)
: throw new InvalidOperationException("Could not find type symbol for: " + node);
private Type ResolveType(ITypeSymbol typeSymbol, Dictionary<string, Type>? genericParameterMap = null)
{
switch (typeSymbol)
{
case INamedTypeSymbol { IsAnonymousType: true } anonymousTypeSymbol:
_anonymousTypeDefinitions ??= LoadAnonymousTypes(anonymousTypeSymbol.ContainingAssembly);
var properties = anonymousTypeSymbol.GetMembers().OfType<IPropertySymbol>().ToArray();
var found = _anonymousTypeDefinitions.TryGetValue(
properties.Select(p => p.Name).ToArray(),
out var anonymousTypeGenericDefinition);
Check.DebugAssert(found, "Anonymous type not found");
var constructorParameters = anonymousTypeGenericDefinition!.GetConstructors()[0].GetParameters();
var genericTypeArguments = new Type[constructorParameters.Length];
for (var i = 0; i < constructorParameters.Length; i++)
{View on GitHub (pinned to dbf9771522)
Solutions
- Add the missing assembly reference that defines the type.
- Fix any compile errors in the source (Roslyn returns null type info for error-laden nodes).
- Avoid 'dynamic' in code intended for C#-to-LINQ translation.
Defensive patterns
Strategy: validation
Validate before calling
// Verify Roslyn can resolve a type for every node you will translate
foreach (var node in nodesToTranslate)
{
if (semanticModel.GetTypeInfo(node).Type is null)
throw new InvalidOperationException(
$"Cannot resolve type for node '{node}' - check references and source errors.");
} Prevention
- Ensure the source compiles cleanly before translation (errors produce null type info).
- Avoid 'dynamic' in translatable query code.
- Include all project references in the Compilation.
When it happens
Trigger: Any syntax node whose type info is unresolved: dynamic usage, error types from syntax errors, unresolvable generic constraints, or types from unreferenced assemblies.
Common situations: Missing project/assembly references; 'dynamic' usage in translated query code; syntax errors in the source causing Roslyn to emit error types; incremental compilation staleness.
Related errors
- Could not found symbol for parameter lambda: {parameter}
- Failed to compile migration '{migrationId}'. Errors: {errors
- Could not resolve type symbol for: {parameter.Type}
- ArrayCreation: non-array type symbol: {arrayCreation}
- No type for expression {elementAccessExpression.Expression}
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/6f0af036fde3471d.
Report an issue: GitHub.