create entity data model using ado.net entity framework designer in visual studio
The ADO.NET Entity Data Model can be created in two ways. One using the ADO.NET Entity Data Model Designer and the other using the command line Entity Data Model Designer - EdmGen.exe
In this article we will learn how to create an Entity Data Model using the ADO.NET Entity Data Model Designer which is a Visual Studio tool. Using this method we can use the graphical user interface and also drag and drop features. See this article to know how to create ADO.NET Entity Data Model using command line utility.
Now we will create SalesOrderManagement Entity Data Model based on the SalesOrderManagement using the ADO.NET Entity Data Model Designer. The database is small and compact because I kept it simple for this exercise. The SalesOrderManagement database contains two tables. They are:
To create an entity data model using the ADO.NET Entity Data Model Designer, follow these simple steps:
- Create a new application of your choice, it can be a Console application or windows application.
- In the solution explorer window, right click on the project and select Add-> New Item option.
- In the Add New Item dialog box, Select the Ado.Net entity data model template as shown in the below figure. Give the name as SoModel to your data model and click the Add button.
- The Entity Data Model Wizard is displayed. Select the option Generate from Database option and click on the Next button.
- In the next dialog box, select the Connection and give a name to entity connection string as SalesOrderManagementEntities and click on Next button.
- In the next screen of Entity Data Model wizard, select the database objects like tables, views and stored procedures to include in the data model.
- Expand the Tables node and select two tables - Customer and order and click the Finish button. Note that the database SalesOrderManagement does not contain any views or stored procedures.
- A new model will be displayed in the designer window in the solution explorer as shown below. The generated Entity Data Model is saved with the name SoModel.edmx.