Reverse engineers an existing database and generates EntityFramework Code First POCO classes, Configuration mappings and DbContext.
EntityFramework Reverse POCO Code First Generator
Reverse engineers an existing database and generates Entity Framework Code First Poco classes, Configuration mappings and DbContext.
Beautifully generated code first code that is fully customisable
Supports EF6, EfCore 2 to 7.
Free to academics (you need a .edu or a .ac email address [contact me if you don't]), not free for commercial use.
Watch the v2 in-depth course at pluralsight I cover everything the v2 generator can do, and show you step-by-step how to reverse engineer your database properly.
Watch a short video clip (no audio)
Please note, this is not the Microsoft reverse generator.
This generator creates code as if you reverse-engineered a database and lovingly created the code by hand.
It also allows you to customise the generated code to your liking.
To remove the trail restrictions, you will require a licence key
Free to academics (you need a .edu or a .ac email address), not free for commercial use.
Go to the ReversePOCO website to obtain/purchase your licence key.
This generator was designed to be customisable from the very beginning,
and not fixed and rigid like other generators.
Go and play with the settings in the <database>.tt file; that's what it's there for.
If your database changes, simply re-save the <database>.tt file. That's it.
There is a dependency on EF6.Utility.CS.ttinclude which is included during VisualStudio installation if you select the component Microsoft.VisualStudio.Component.EntityFramework, which can be selected from the list of optional packages under the "ASP.NET and web development" workload, and is listed as "Entity Framework 6 tools".
Use Nuget and install the relevant NuGet package for your database.
Settings.ConnectionString is mandatory in v3, so you need to provide the connection string from your app.config/web.config/appsettings.json file. This connection string is used by the generator to reverse-engineer your database. It no longer reads your connection strings from *.config files.
Settings.ConnectionStringName Not used by the generator, but is placed into the generated DbContext constructor via a call to Settings.DefaultConstructorArgument.
A simple UI for the generator is available at
GitHub, which helps you to create a regex to filter your tables.
Editing TT (T4) Files
To have full syntax highlighting and IntelliSense when editing TT files, I use the Resharper plugin ForTea. I can't imagine editing TT files without it.
With the new v3, you no longer have to edit the EF.Reverse.POCO.v3.ttinclude file, as this file is now generated from a C# project. This repository includes the BuildTT file, which creates the EF.Reverse.POCO.v3.ttinclude from the Generator C# project.