Reverse engineers an existing database and generates EntityFramework Code First POCO classes, Configuration mappings and DbContext. Works for SQL Server and SQL Server Compact 4.0
Watch the in-depth course at pluralsight I cover everything this generator can do, and show you step-by-step how to reverse engineer your database properly.
A simple UI for the generator is available here.
Highly customisable output
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 .tt file, that's what it's there for.
If your database changes, simply re-save the .tt file. It's that simple good.
- Support EF Core
- Support other databases: PostgreSQL, Oracle, MySQL, etc.
To make a donation, please click here.
YOU have full control over the generated code
See list here
To install and use this project:
- For Visual Studio 2012 & 2013, install Entity Framework 6 Tools available here from www.microsoft.com/en-us/download/details.aspx?id=40762 This installs the required EF6.Utility.CS.ttinclude which is used for pluralisation. You only need to do this once.
- Use Nuget and install EntityFramework.
- Add a connect string to your app.config. Somethine like:
- The connection string you use must have at least these privileges: ddladmin, datareader and datawriter. ddladmin is required for reading the default constraints.
- In Visual Studio, right click project and select "add - new item".
- Select Online, and search for "reverse poco". Or you can download it from this page (use Download button at the top). By downloading and installing it, it will be permanently available in your "Add item" templates.
- Select "EntityFramework Reverse POCO Generator".
- Give the file a name, such as Database.tt and click Add.
- Edit the Database.tt file and specify the connection string as "MyDbContext" which matches your connection string name in app.config.
- Save the Database.tt file, which will now generate the Database.cs file.
- There are many options you can use to customise the generated code. All of these settings are in the Database.tt files.
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.