This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the EntityFramework Reverse POCO Code First Generator (EFRPG) — a Visual Studio extension and T4 template system that reverse-engineers an existing database and generates EF Code First POCO classes, DbContext, interface, configuration mappings, enumerations, fake DbContext (for unit testing), and stored procedure/TVF callers.
The generator is distributed as a VSIX (Visual Studio Extension) containing a T4 item template. Users add a Database.tt file to their project; saving it triggers the generator.
Generator/— Core library (Efrpgnamespace,netstandard2.0). All generation logic lives here.BuildTT/— Console app that compiles theGenerator/C# project into a single.ttincludefile (EF.Reverse.POCO.v3.ttinclude) that ships with the extension.EntityFramework.Reverse.POCO.Generator/— The.ttincludefile output from BuildTT, plus theDatabase.tttemplate that users add to their projects.EntityFramework Reverse POCO Generator/— VSIX packaging project.Generator.Tests.Unit/— Unit tests using NUnit (targetsnet48, requires SQL Server LocalDB for some tests).Generator.Tests.Unit.EFCore/— EF Core-specific unit tests (targetsnet8.0).Generator.Tests.Integration/— Integration tests that actually connect to SQL Server and write generated files to~/Documents.Generator.Tests.Common/— Shared test constants and helpers (netstandard2.0).Tester.Integration.EFCore8/,EFCore9/,Ef6/— Projects that consume the generated output and verify it compiles/runs correctly.Tester.Repository/,Tester.BusinessLogic.EfCore/— Support projects for integration testing._File based templates/— Mustache template files for theFileBasedtemplate mode.
- Settings (
Generator/Settings.cs) — static class holding all configuration. The.ttfile sets these before running. - DatabaseReader (
Generator/Readers/) — reads schema from the database.DatabaseReaderFactoryselects the reader based onSettings.DatabaseType(SqlServer, PostgreSQL, SQLite, SqlCe, MySql, Oracle, or Plugin). - Generator (
Generator/Generators/) — abstract base class withGeneratorEf6,GeneratorEfCore, andGeneratorCustomimplementations. Selected byGeneratorFactorybased onSettings.GeneratorType. - Template (
Generator/Templates/) — abstract base class withTemplateEf6,TemplateEfCore8, andTemplateFileBasedimplementations. Mustache-based string templates. Selected byTemplateFactorybased onSettings.TemplateType. - Filtering (
Generator/Filtering/) —FilterSettingsandSingleContextFilter/MultiContextFiltercontrol which schemas/tables/columns/stored procs are included. - FileManagement (
Generator/FileManagement/) — handles writing output files; different implementations for EF Core projects, VS4.x projects, and null (test mode).
BuildTT concatenates all C# files from Generator/ into one large EF.Reverse.POCO.v3.ttinclude file. Never edit the .ttinclude directly — edit the source files in Generator/ and run BuildTT to regenerate.
Version is controlled by BuildTT/version.txt.
TemplateType.EfCore9/EfCore8→ usesTemplateEfCore8class with Mustache templates inline in C#TemplateType.Ef6→ usesTemplateEf6classTemplateType.FileBasedCore8/9/FileBasedEf6→ usesTemplateFileBasedwhich reads fromSettings.TemplateFolder(Mustache.mustachefiles)
When Settings.GenerateSingleDbContext = false, a plugin class implementing IMultiDbContextSettingsPlugin drives generation of multiple DbContext classes from one database.
# Build the solution
dotnet build EF.Reverse.POCO.GeneratorV3.sln
# Run unit tests (no DB required for most)
dotnet test Generator.Tests.Unit/Generator.Tests.Unit.csproj
# Run EF Core unit tests
dotnet test Generator.Tests.Unit.EFCore/Generator.Tests.Unit.EFCore.csproj
# Run integration tests (requires SQL Server with EfrpgTest and Northwind databases)
dotnet test Generator.Tests.Integration/Generator.Tests.Integration.csproj --filter "Category=Integration"
# Run a single test by name
dotnet test Generator.Tests.Unit/Generator.Tests.Unit.csproj --filter "FullyQualifiedName~PluralisationTests"pack.bat packages the VSIX item template (requires 7-Zip at C:\Program Files\7-Zip\7z.exe). Run after building if you need to update the VSIX item template zip.
- Unit tests use
FakeDatabaseReaderto avoid real DB connections. - Integration tests connect to
(local)SQL Server usingIntegrated Security=True. Test databases areEfrpgTestandNorthwind(SQL scripts inTestDatabases/andEfrpgTest.sql). - Integration tests write generated
.csfiles to~/Documentssub-folders like.V3TestE8. - The
Tester.Integration.*projects compile the generated output to verify it. - Test categories:
Constants.DbType.SqlServer,Constants.DbType.PostgreSQL,Constants.Integration.