{"record":{"id":"a46ce93698ef4e5c","repo":"dotnet/efcore","slug":"failed-to-resolve-type-for-directive-processor-na","errorCode":null,"errorMessage":"Failed to resolve type for directive processor {name}.","messagePattern":"Failed to resolve type for directive processor (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Scaffolding/Internal/TextTemplatingEngineHost.cs","lineNumber":216,"sourceCode":"        {\n            return Assembly.Load(assemblyReference).Location;\n        }\n        catch\n        {\n        }\n\n        // TODO: Expand variables?\n        return assemblyReference;\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual Type ResolveDirectiveProcessor(string processorName)\n        => throw new FileNotFoundException(DesignStrings.UnknownDirectiveProcessor(processorName));\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual string ResolveParameterValue(string directiveId, string processorName, string parameterName)\n        => string.Empty;\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual string ResolvePath(string path)\n        => !Path.IsPathRooted(path) && Path.IsPathRooted(TemplateFile)","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Scaffolding/Internal/TextTemplatingEngineHost.cs#L198-L234","documentation":"Thrown by the T4 text-templating host when the templating engine asks it to resolve a directive processor by name and the host has no registration for it. EF Core's built-in host only supports the directives it ships; any other directive processor name yields a FileNotFoundException so the template fails fast instead of silently emitting broken code.","triggerScenarios":"A custom DbContext.t4 / EntityTypeConfiguration.t4 template contains a `<#@ directive processor=\"...\" #>` directive whose processor name is not registered in the EF Core TextTemplatingEngineHost. Reached when TextTemplatingModelGenerator compiles the user template.","commonSituations":"Copying a T4 template that depends on Visual Studio's directive processors (e.g. the VS host or a custom data directive processor) into an EF Core scaffolding templates folder. Editing a template on a machine without the referenced processor assembly.","solutions":["Remove the unsupported `<#@ directive processor=\"...\" #>` directive from your .t4 template; EF Core only supports self-contained templates.","Replace the directive processor logic with inline helper code or a <#+ class function block #> in the template.","If you truly need a custom processor, port the template to the standalone T4 host or to EF Core's CSharpDbContextGenerator model.","Diff your template against the EF Core default templates to find unsupported directives."],"exampleFix":"// before\n<#@ template language=\"C#\" #>\n<#@ directive processor=\"PropertyProcessor\" #>\n// after\n<#@ template language=\"C#\" #>\n<# // inline any logic the processor provided #>","handlingStrategy":"validation","validationCode":"// Scan your .t4 templates for unsupported directives before scaffolding\nvar disallowed = new[] { \"directive processor\" };\nforeach (var t4 in Directory.GetFiles(templatesDir, \"*.t4\"))\n  foreach (var line in File.ReadAllLines(t4))\n    if (disallowed.Any(d => line.Contains(d)))\n      Console.Error.WriteLine($\"Unsupported directive in {t4}: {line}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Author T4 templates to be self-contained; avoid external directive processors.","Compare custom templates to the EF Core defaults to detect unsupported directives.","Test templates with a minimal model before committing them."],"tags":["t4","templating","scaffolding","design-time"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}