Skip to content
Simon Hughes edited this page Aug 30, 2026 · 44 revisions

EntityFramework Reverse POCO Code First Generator

The generator creates Entity Framework Code First classes by reverse-engineering existing databases. It produces code as if an expert reverse-engineered your database and wrote it for you.

Key Features

  • Generates POCO classes, configuration mappings, and enumerations
  • Creates DbContext and FakeDbContext for unit testing
  • Supports stored procedures and table-valued functions
  • Fully customisable output via callbacks and delegates
  • Available as a VSIX installer from the Visual Studio Marketplace
  • Supports multiple output file organisation strategies (sub-folders, namespaces)

Give a Star! ⭐

If you like or are using this project, please give it a star. Thanks!

Watch a short video clip (no audio)

Watch the video

New in v4 🚀

v4 moves all database reading out of the T4 template and into a separate dotnet tool, efrpg. The template runs the tool; the tool hands back the schema as XML.

The reason that matters to you:

  • MySQL and Oracle are now fully supported, joining SQL Server, PostgreSQL and SQLite.
  • No more GAC installs, no more machine.config edits. Database drivers are ordinary NuGet dependencies of the tool. If you followed the old PostgreSQL, Oracle, MySQL or SQLite setup instructions, you can undo all of it.
  • Your connection string is passed to the tool over stdin, so it stays out of process listings and command-line audit logs.

You must install the tool, or nothing will generate. See step 2 below, and Upgrading from v3 to v4 for the full upgrade.

Gone in v4: DatabaseType.SqlCe, DatabaseType.Plugin, Settings.DatabaseReaderPlugin and Settings.FileManagerType.

Supported Databases

Database Status Notes
SQL Server Fully supported The most complete implementation
PostgreSQL Fully supported
MySQL / MariaDB Fully supported New in v4. One database = one schema
Oracle Fully supported New in v4. One schema per run
SQLite Fully supported No stored procedures in SQLite

SQL Server Compact was removed in v4. It reached end of support in July 2021 and has no provider for modern .NET. Stay on v3 until you have migrated the database, typically to SQLite or LocalDB.

Supported EF Versions

EF Version Template Type Generator Type
EF 6 TemplateType.Ef6 GeneratorType.Ef6
EF Core 8 TemplateType.EfCore8 GeneratorType.EfCore
EF Core 9 TemplateType.EfCore9 GeneratorType.EfCore
EF Core 10 TemplateType.EfCore10 GeneratorType.EfCore

Match TemplateType to the EF Core version your project references, not your .NET version. See Support Planning.

Installation Requirements

  • Visual Studio 2022 or later

  • The .NET 10 runtime, for the efrpg tool

  • The EF provider NuGet package for your database, in your project:

    Database EF Core package EF 6 package
    SQL Server Microsoft.EntityFrameworkCore.SqlServer EntityFramework
    PostgreSQL Npgsql.EntityFrameworkCore.PostgreSQL n/a
    MySQL Pomelo.EntityFrameworkCore.MySql n/a
    Oracle Oracle.EntityFrameworkCore n/a
    SQLite Microsoft.EntityFrameworkCore.Sqlite n/a
  • A connection string pointing at your database, with read access to the schema. See Connection strings for the exact permissions per database.

Quick Start

  1. Install the VSIX extension from the Visual Studio Marketplace.

  2. Install the efrpg tool. Once per machine, shared by every project on it:

    dotnet tool install -g Efrpg
    

    Check it is on your PATH with efrpg --help. Restart Visual Studio afterwards - it caches the environment it was started with, so a PATH change made while it was running is invisible to it.

  3. Right-click your project → Add New Item

  4. Search for "reverse poco" in online templates

  5. Name the file (e.g. Database.tt) and click Add

  6. Edit the connection string and settings

  7. Save the file — Database.cs (and related files) are generated automatically

Every time your database changes, re-save the .tt file. Building does not re-run the generator; only saving does.

Recommended Settings

.NET / EF Core 10 (latest)

Settings.DatabaseType     = DatabaseType.SqlServer;
Settings.TemplateType     = TemplateType.EfCore10;
Settings.GeneratorType    = GeneratorType.EfCore;
Settings.UseMappingTables = false;

.NET / EF Core 9

Settings.DatabaseType     = DatabaseType.SqlServer;
Settings.TemplateType     = TemplateType.EfCore9;
Settings.GeneratorType    = GeneratorType.EfCore;
Settings.UseMappingTables = false;

.NET / EF Core 8

Settings.DatabaseType     = DatabaseType.SqlServer;
Settings.TemplateType     = TemplateType.EfCore8;
Settings.GeneratorType    = GeneratorType.EfCore;
Settings.UseMappingTables = false;

.NET Framework / EF 6

Settings.DatabaseType     = DatabaseType.SqlServer;
Settings.TemplateType     = TemplateType.Ef6;
Settings.GeneratorType    = GeneratorType.Ef6;
Settings.UseMappingTables = true;

Settings.FileManagerType no longer exists in v4 - output is always written the same way. Delete the line when upgrading.

Where to go next

Getting it working

Shaping the output

Modelling features

Bigger jobs

Licensing

  • Free for academic use (.edu or .ac email addresses)
  • Commercial license required for commercial use — purchase at reversepoco.co.uk
  • Generated code remains usable indefinitely even if the licence expires
  • With an expired licence, generation is limited to 10 tables/views and 10 stored procedures

See Licencing & expires licence and ReversePOCO.txt licence file.

Contributing

See How to Get Your Pull Request Accepted for contribution guidelines.

Contact: simon@reversepoco.co.uk

Clone this wiki locally