Version 4
v4 moves database reading out of the T4 template and into a separate command-line tool, efrpg. The template no longer opens a connection itself: it runs the tool, and the tool hands back the schema. That one change removes the long tail of provider-loading problems v3 had inside the Visual Studio T4 host, and it is why the upgrade needs more than a new .ttinclude.
You need both parts:
dotnet tool install -g Efrpg
plus this extension. The tool needs the .NET 10 runtime, installs once per machine, and is versioned independently of the extension. Everyone who regenerates code needs it.
Already on v3? Read Upgrading from v3 to v4. The include is versioned in its file name, so v3 and v4 sit side by side in one project and you can migrate one template at a time. The right-click Upgrade this template to v4 command makes the edits for you and shows them before writing.
What's new
Database reading
- The
efrpgdotnet tool reads the schema in its own .NET 10 process. Provider versions are the tool's problem now, not your project's: no more could not load file or assembly Npgsql / MySql.Data / System.Data.SQLite, no provider mismatches between your project and the T4 host, no 32-bit/64-bit surprises. - MySQL and Oracle are now fully supported 🚀
- SQL Server, PostgreSQL and SQLite continue as before.
- Your connection string is passed to the tool over
stdin, so it never appears in process listings or command-line audit logging. - No Visual Studio component prerequisite. v3 needed the Entity Framework 6 tools component; v4 does not. The template no longer depends on
EF6.Utility.CS.ttinclude,EnvDTEorMicrosoft.VisualStudio.TextTemplating. - The tool and template check that they can talk to each other and say so plainly when the tool is missing or too old.
Entity Framework
- Supports EF6 and EF Core 8, 9 and 10.
- EF Core: table comments are written inside
ToTable(...), so the generated code compiles without theHasCommentobsolete warning on EF Core 10.
Visual Studio GUI - new in v4, all from the item template and the right-click menu on a .tt
- Adding the item now asks for the database type, EF version and connection string, tests the connection with the real tool, and writes the result into the new
.tt. It also derives the namespace and offers common output options: separate files, file-scoped namespaces, the unit-testing fake context, and debug-only fakes. - Choose tables, views and stored procedures from a checkbox tree and have the filters written into the
.tt, including schema filters. - Settings editor for every setting, grouped as they are in
Database.tt, with a search box and a link from each setting to its wiki page. Multi-line lists get a proper editor, and every change appears before it saves. - Enums page: see the enumerations already declared and add one from a dropdown of candidate tables, filtered as you type.
- Callbacks page: switch each callback on or off with a tick, see its code syntax-coloured by Visual Studio, and jump straight to it in the
.tt. - Upgrade this template to v4: converts a v3
.ttin place, deletes the settings v4 removed, and refuses a file that depends on a removed feature, saying which.
Elsewhere
- JetBrains Rider runs the template too, without the extension: add
Database.ttandEF.Reverse.POCO.v4.ttincludeto the project and run it from Rider's T4 menu. See JetBrains Rider. - On any host that does not supply a namespace hint, the generator derives the namespace from the
.csproj. - Visual Studio 2026 is supported alongside 2022.
- Values a database can hold that XML cannot, such as control characters and lone surrogates, no longer break a run.
- The wiki has a page for every setting, and every generated-code example on it is produced by the generator and checked for drift, so the documentation cannot quietly stop being true. Start at the Settings Reference.
- The project now lives under the ReversePOCO organisation. Old links redirect.
Deprecated and removed
Each of these stays exactly as it was in v3, which remains downloadable and continues to work, so a project that depends on one keeps using v3.
- Visual Studio 2017 and 2019 are no longer supported. v4 needs Visual Studio 2022 or later.
- SQL Server Compact (
DatabaseType.SqlCe). It reached end of support in July 2021 and has no provider for modern .NET. - Custom database reader plugins (
Settings.DatabaseReaderPlugin,DatabaseType.Plugin). A plugin was a .NET Framework assembly loaded into the T4 host, and there is nothing to load it into anymore. If yours reads a database we don't support, please open an issue; that is a case for adding the dialect to the tool. - Multiple DbContexts in one go (
Settings.GenerateSingleDbContext = false, theSettings.MultiContext*settings, theMultiContext.*settings tables and the tool's--multi-contextoption). The v4 generator always produces one context; use the filters to shape it. - File-based templates (
TemplateType.FileBased*,Settings.TemplateFolder). The templates live insideEF.Reverse.POCO.v4.ttinclude; edit them there and keep the edit as a patch to reapply on upgrade. Settings.GeneratorType, includingCustomand theGeneratorCustomclass.TemplateTypealone decides which generator runs.- JavaScript output (
Settings.GenerationLanguage,Settings.FileExtension). The v4 generator only writes C# to.csfiles. Settings.IncludeQueryTraceOn9481Flag, the SQL Server 2014 cardinality-estimator workaround.Settings.FileManagerType. Output is always written the same way. This means older C# projects'.csprojfiles should be upgraded to the newer SDK format to use v4; otherwise, stay on v3.DatabaseReader.CleanUp(...)is nowNamingHelper.CleanUp(...), since the reader moved into the tool.
Everything else - ConnectionString, TemplateType, all of FilterSettings, the naming callbacks, ElementsToGenerate, the folder settings - is unchanged. Unlike v2 to v3, this is not a settings rewrite: for most projects on SQL Server, PostgreSQL or SQLite the generated output is identical.