Web Dev/Legacy Rescue

Introduction to Entity Framework Power Tools

Streamline legacy system upgrades with Entity Framework Power Tools. Learn how to reverse engineer database tables into code-first entities.

An abstract image of a man holding a laptop pointing to a monitor

So, you’ve got a legacy system and have decided to make the smart move of embracing domain driven design. To this end, you’ve decided to introduce Entity Framework into your system in order to facilitate expressing your domain in an ubiquitous language. You are clearly very smart because you’ve also decided to use the code-first approach which is the ideal methodology for doing test driven design.

If your existing system is quite large, then the prospect of hand coding all the entities that already exist in your database might seem a bit of a tedious task. Reverse engineering however is a great way to save time. Don’t get me wrong, I am not suggesting throwing away all of the good stuff like TDD or DDD. All I’m saying is minimize menial labour by quickly generating the entities that you want to start with and then expand on them through TDD and DDD.

For this purpose, the Entity Framework team created a handy little tool called “Entity Framework Power Tools”. The tool is still in Beta as we speak but already showing a lot of promise. It gives you control over the code that is generated meaning that if you want to customise the code that is produced (to meet with your company’s standards), you are then able to edit the T4 templates used for code generation. Sadly it’s missing the feature enabling you to select only the specific tables you want to reverse engineer, but we forgive this little fault considering what it has saved us on labour.

A Demonstration

In demonstrating this tool, please note that it is assumed that you are already familiar with entity framework and understand how the DbContext, Entities and EntityConfiguration files work together.

The Power Tools are installed through the Extension Manager in Visual Studio. Open Visual Studio, click on Tools and then Extension Manager. In the search bar, type “Entity Framework Power Tools”.

Power Tools in Visual Studio

Using your Power Tools

Before we begin, I need to point out that the reverse engineering process will work better if you have foreign keys defined on your tables. The power tools will also be able to form more meaningful relationships between your entities if you do. If you don’t have foreign keys defined, the tool will only automatically generate the entities (with scalar properties) and not the relationships to other entities. It is therefore advisable to invest some time in setting up these foreign keys before you begin to reverse engineer. This will save you a lot more effort in the long run.

I would also suggest that you consider getting a great refactoring tool such as Resharper to speed up the refactoring of your legacy code, especially when you are creating large volumes of new code through reverse engineering.

Let’s create some tables on a database first

For the purpose of this demonstration, create the following tables on a test database that you have access to:

Now, let’s reverse engineer our tables!

  • Create a new blank solution in visual studio.
  • Create a Class library for your domain entities.
  • Right-click on the class library project file; the Entity Framework menu only appears on the project sensitive menu.
  • Select the “Entity Framework” menu.
  • Select “Reverse Engineer Code First”

On Connection Properties, enter your connection details (I called my database KRSPurchase):

At this point the power tools will do the following:

  1. Create a “Models” folder.
  2. Create a subfolder called “Mappings”.
  3. Create an entity configuration file for each table that it finds.
  4. Create an entity for each table.
  5. Create a DbContext file.
  6. Create an app.config file with the connectionstring that you specified.

Looking for a software partner?

Tell us about your project and we’ll show you how our team can help.

Contact Us

Found this useful? Share it.

Written by

KRS

More musings →

Keep reading

A photograph of a computer screen displayng code Web Dev/Legacy Rescue

4 November 2025 · KRS

Why KRS Chooses Svelte for Custom Software Development

KRS specialises in Svelte development & custom software development in South Africa, delivering fast, scalable business solutions.

Interface mockup with glass effect Web Dev/Legacy Rescue

10 July 2025 · Elizabeth Duff

Modern UX for Legacy Software: How to Upgrade with SPA Design Principles

Learn how to upgrade legacy software with modern SPA design principles, improving performance, usability, and user satisfaction.

Best10 Personalised nutrition and fitness platform developed by KRS screenshot of meal plans Web Dev/Legacy Rescue

15 March 2024 · Elizabeth Duff

KRS: The development team behind Best10

The Best10 platform offers personalised nutrition and fitness support, and KRS is proud to be the development team behind the platform