MVC5 Classic
wijmenu Step 1 of 3: Creating the Model

The Model contains all of the database access, business, and validation logic. In this example, we'll generate an ADO.NET Entity Data Model (.edmx), from the view stored in the NorthWND.MDF database.

Note: This step assumes that you have created an MVC Classic project. If you haven’t, see the Creating an MVC Classic Project topic. It also assumes that you have added the NORTHWND.MDF database installed with the product to the project's App_Data folder. The NORTHWND.MDF file can be found in the Documents\ComponentOne Samples\Common.
  1. Complete the following steps:.In the Solution Explorer, right click App_Data and select Add | Existing Item. Select NORTHWND.MDF in the App_Data folder and click Add.
  2. Right-click the Models folder and select Add | New Item.
  3. In the Add New Item dialog box, choose  Data under Visual C#.
  4. Select ADO.NET Entity Data Model, enter a name, such as MyNorthWindEDM, in the Name field, and click Add. The Entity Data Model Wizard appears.
  5. Select Generate from database and click Next.
  6. In the Choose Your Data Connection dialog box, click New Connection. The Choose Data Source dialog box appears.
  7. Select Microsoft SQL Server Database File and click Continue.
  8. Browse to find the NORTHWND.MDF file in the project’s App_Data folder and click Open.
  9. You can test the connection and click OK.
  10. You can leave Save Entity Settings in Web.Config as NORTHWNDEntities checked and click Next.
  11. In the Choose Your Database Objects window, expand the Tables node, select the Products and Categories check boxes and click Finish.
    The model, in this case MyNorthWindEDM.edmx, is created and added to the Models folder of the project.

In the next step, wijmenu Step 2 of 3: Creating the Controller, we’ll create a controller, which will handle the user action by returning a view that contains the data from the model.

 

 


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

Product Support Forum |  Documentation Feedback