The Model contains all of the database access, business, and validation logic. In this example, you'll generate an ADO.NET Entity Data Model (.edmx), from the Products table of the NORTHWND.MDF database.
Complete the following steps:
- In the Solution Explorer, right-click the App_Data folder and select Add | Existing Item.
- In the Add Existing Item dialog box, locate and select the NORTHWND.MDF file and click Add.
- Right-click the Models folder and select Add | New Item.
- In the Add New Item dialog box, choose Data under your selected programming language.
- Select ADO.NET Entity Data Model, enter a name, such as MyNorthWindEDM.edmx, in the Name field, and click Add. The Entity Data Model Wizard appears.
- Confirm that Generate from database is selected and click Next.
- On the Choose Your Data Connection screen, click New Connection.The Choose Data Source dialog box appears.
- Select Microsoft SQL Server Database File and click Continue.
- Click the Browse button to locate the NORTHWND.MDF file in the project's App_Data folder and click Open.
- If you choose, click the Test Connection button. Then click OK to close the Connection Properties dialog box.
- Confirm that Save entity connection settings in Web.Config as: NORTHWNDEntities is selected and click Next.
- In the Choose Your Database Objects screen, expand the Tables node, select Products, and click Finish.
The model, in this case MyNorthWindEDM.edmx, is created and added to the Models folder of the project.
In the previous step, you created a model. In the next step, wijgrid Step 2 of 4: Creating the Controller, you'll create a controller, which will handle the user action by returning a view that contains data from the model.