{"record":{"id":"c96d9d9222bf956c","repo":"dotnet/efcore","slug":"could-not-find-type-symbol-for-fullyqualifiedmet-c96d9d","errorCode":null,"errorMessage":"Could not find type symbol for: {fullyQualifiedMetadataName}","messagePattern":"Could not find type symbol for: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/EFCore.Design/Query/Internal/QueryLocator.cs","lineNumber":366,"sourceCode":"            _compilation = compilation;\n\n            IQueryableOfT = GetTypeSymbolOrThrow(\"System.Linq.IQueryable`1\");\n            IQueryable = GetTypeSymbolOrThrow(\"System.Linq.IQueryable\");\n            DbContext = GetTypeSymbolOrThrow(\"Microsoft.EntityFrameworkCore.DbContext\");\n            DbSet = GetTypeSymbolOrThrow(\"Microsoft.EntityFrameworkCore.DbSet`1\");\n\n            Enumerable = GetTypeSymbolOrThrow(\"System.Linq.Enumerable\");\n            IEnumerableOfT = GetTypeSymbolOrThrow(\"System.Collections.Generic.IEnumerable`1\");\n            Queryable = GetTypeSymbolOrThrow(\"System.Linq.Queryable\");\n            EfQueryableExtensions = GetTypeSymbolOrThrow(\"Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions\");\n        }\n\n        public static Symbols Load(Compilation compilation)\n            => new(compilation);\n\n        private INamedTypeSymbol GetTypeSymbolOrThrow(string fullyQualifiedMetadataName)\n            => _compilation.GetTypeByMetadataName(fullyQualifiedMetadataName)\n                ?? throw new InvalidOperationException(\"Could not find type symbol for: \" + fullyQualifiedMetadataName);\n    }\n}\n","sourceCodeStart":348,"sourceCodeEnd":369,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/QueryLocator.cs#L348-L369","documentation":"Thrown in QueryLocator.Symbols.GetTypeSymbolOrThrow (line 366) while loading the core symbols QueryLocator needs to locate queries in source. It resolves a fixed list (IQueryable`1, IQueryable, DbContext, DbSet`1, Enumerable, IEnumerable`1, Queryable, EntityFrameworkQueryableExtensions); if any is absent from the compilation it throws. Like error 288 it signals the analysis compilation is missing essential EF/Linq references, so query location cannot proceed.","triggerScenarios":"QueryLocator.Symbols.Load runs on a Compilation where GetTypeByMetadataName returns null for one of the required types (e.g. Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore.DbSet`1, or System.Linq.Queryable). GetTypeSymbolOrThrow throws immediately.","commonSituations":"The project being scanned for precompiled queries does not reference the EF Core assembly (no DbContext/DbSet symbols) or System.Linq. The analyzer host provided an incomplete Compilation. Running against a non-EF project by mistake. A stripped reference set in CI/source-generator contexts.","solutions":["Ensure the target project references EF Core (DbContext/DbSet/EntityFrameworkQueryableExtensions) and System.Linq.","Run precompiled-query tooling only against projects that actually contain a DbContext.","Verify the analyzer receives the project's full reference graph; fix any host that drops references.","Restore packages and clean/rebuild so the compilation includes all referenced assemblies."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm EF/Linq symbols are visible before QueryLocator loads\nstring[] required = {\n    \"Microsoft.EntityFrameworkCore.DbContext\",\n    \"Microsoft.EntityFrameworkCore.DbSet`1\",\n    \"System.Linq.Queryable\"\n};\nif (required.Any(n => compilation.GetTypeByMetadataName(n) is null)) { /* add EF Core references */ }","typeGuard":null,"tryCatchPattern":"try { QueryLocator.Symbols.Load(compilation); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Could not find type symbol\"))\n{ /* ensure the project references EF Core, then retry */ }","preventionTips":["Run query location/precompilation only against DbContext projects.","Ensure the analyzer receives the full reference graph.","Restore and rebuild to populate references."],"tags":["ef-core","precompiled-query","type-resolution","roslyn","design-time"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}