- Open Visual Studio.
- Make sure you have the latest version of the entity framework.
- Create a project or open an existing project (Preferably C# Console Application)
- Right-click the project and choose Add -> New Item…
- Under Visual C# Items select “Data”
- Select the template “ADO.NET Entity Data Model”
- Give it a name and click “Add”
- Select “Generate from database”
- Enter connection info, choose the database objects and Visual Studio will create a model of the database
- 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.
- 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
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.