01 Feb


  1. Open Visual Studio.
  2. Make sure you have the latest version of the entity framework.
  3. Create a project or open an existing project (Preferably C# Console Application)
  4. Right-click the project and choose Add -> New Item…
  5. Under Visual C# Items select “Data”
  6. Select the template “ADO.NET Entity Data Model”
  7. Give it a name and click “Add”
  8. Select “Generate from database”
  9. Enter connection info, choose the database objects and Visual Studio will create a model of the database
  10. Once you have the model ready, you can move around the tables, or create or edit or delete tables, create relationships and ultimately even send those changes to the database.
  11. For exporting the ER model as an image, just right-click on the blank space, select Diagram, and select Export as image.

The model is stored as a “.edmx” file and will look something like this 

Related image

Using the Entity Data Model Designer you can even build logical tables from scratch, then create the DDL that can be run on SQL Server to build the physical tables. Or, you can generate the logical tables from an existing SQL Server database – reverse engineering, modify them, and update the physical tables. One other feature is that it creates the .NET code to interact with the tables if you are building an application. In our case, we only need to create an Entity-Relationship diagram of an existing database, so well skip it.