Skip to content

Settings.TemplateFolder

Simon Hughes edited this page Aug 30, 2026 · 1 revision

Settings.TemplateFolder, Settings.GenerationLanguage and Settings.FileExtension

Three settings about the templates that turn the schema into text, and what the text is called.

Setting Type Default
Settings.TemplateFolder string Path.Combine(Settings.Root, "Templates")
Settings.GenerationLanguage GenerationLanguage enum GenerationLanguage.CSharp
Settings.FileExtension string ".cs"

Settings.TemplateFolder

Only read when Settings.TemplateType is one of the FileBased* values. It names the folder holding the Mustache templates the generator will use instead of its built-in ones.

The folder must contain the .mustache and *Usings.txt files directly. It is not a parent holding per-version sub-folders. Copy the contents of the _File based templates\Templates.EFCore10 folder (or whichever matches your TemplateType) into it.

Settings.TemplateType   = TemplateType.FileBasedCore10;
Settings.TemplateFolder = Path.Combine(Settings.Root, "Templates");  // relative to the .tt - recommended
Settings.TemplateFolder = @"c:\shared\efrpg-templates";              // or absolute

File-based templates exist so your changes survive an upgrade. The built-in templates live inside EF.Reverse.POCO.v4.ttinclude, which is replaced wholesale every time you update the extension; a folder of your own is not. See Custom File-Based Templates.

Settings.GenerationLanguage

public enum GenerationLanguage
{
    CSharp,
    Javascript
}

C# is the only language that is fully supported. Javascript swaps in a JavaScript type map and is SQL Server only - every other database silently falls back to C#. It changes the property types only; the templates still emit C# structure around them, so treat it as experimental.

Settings.FileExtension

The extension on generated files. ".cs" unless you have changed GenerationLanguage, in which case set it to match.

Gotchas

TemplateFolder does nothing unless TemplateType is FileBased*. The setting is assigned in the shipped Database.tt regardless, which makes it look active when it is not.

A missing template file fails at generation time, not with a helpful message about which file. If you copied only some of the .mustache files, copy the rest.

Templates are version-specific. Templates.EFCore8 and Templates.EFCore10 differ. Point FileBasedCore10 at an EF Core 8 template folder and you get EF Core 8 output.

Multi-context generation can override the folder per context, through the TemplatePath column of MultiContext.Context. That takes precedence over this setting for that one context.

GenerationLanguage.Javascript is not a JavaScript code generator. It changes types, nothing else. If you want TypeScript models, a file-based template is the honest route.

See also

Clone this wiki locally