MVC5 Classic
wijgrid Step 1 of 4: Creating the Model

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.

Note: This step assumes that you have created an MVC Classic project. See the Creating an MVC Classic Project topicfor more information.

Complete the following steps:

  1. In the Solution Explorer, right-click the App_Data folder and select Add | Existing Item.
  2. In the Add Existing Item dialog box, locate and select the NORTHWND.MDF file and click Add.
  3. Right-click the Models folder and select Add | New Item.
  4. In the Add New Item dialog box, choose Data under your selected programming language.
  5. 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.
  6. Confirm that Generate from database is selected and click Next.
  7. On the Choose Your Data Connection screen, click New Connection.The Choose Data Source dialog box appears.
  8. Select Microsoft SQL Server Database File and click Continue.
  9. Click the Browse button to locate the NORTHWND.MDF file in the project's App_Data folder and click Open.
  10. If you choose, click the Test Connection button. Then click OK to close the Connection Properties dialog box.
  11. Confirm that Save entity connection settings in Web.Config as: NORTHWNDEntities is selected and click Next.
  12. 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.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback