[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Collapse]Pivot Grid
   [Expand]Getting Started
    Integrate the PivotGrid Extension into a Project
   [Collapse]Binding to Data
     Binding to Data using Entity Framework (Code First)
     Binding to Data using Entity Framework or LINQ to SQL (Database First)
     Database Server Mode
    Main Features - PivotGrid
    Client-Side Functionality
   [Expand]UI Elements
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors Extensions
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Query Builder
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Binding to Data using Entity Framework or LINQ to SQL (Database First)

The DevExpress MVC PivotGrid supports binding to an existing data source using the LINQ or the Entity Framework.

If you already have a database, the LINQ to SQL ORM Framework or the Entity Framework ORM can automatically generate a data model that consists of classes and properties that correspond to existing database objects such as tables and columns. This development approach is called "Database First".

This topic describes how to bind the MVC PivotGrid to a data source using the "Database First" development approach.

Project requirements

Your project should be prepared to use DevExpress MVC Extensions. See the following topic to learn how to prepare your project: Integration into an ASP.NET MVC Project.

To implement this kind of data binding, you need to perform the following steps.

Expanded Step 1. Create a data model

Use the required ORM framework to reverse engineer a model from an existing database.

  • LINQ to SQL ORM Framework

    Create a LINQ to SQL data model.

    Refer to the following MSDN Learning Center article to learn more about the LINQ to SQL ORM Framework: LINQ to SQL.

  • Entity Framework ORM


    Before you start, make sure you have the Entity Framework installed. Learn more about how to get the Entity Framework from the following MSDN tutorial: Get Entity Framework.

    Create an Entity Framework data model. The following walkthrough demonstrates how to reverse engineer a model from an existing database: Entity Framework Database First.


Rebuild the solution before going on to the next step.

Expanded Step 2. Add the PivotGrid to the required View

Open the required View file (Index.cshtml in this topic), right-click the desired location in the Code Editor to display the Shortcut menu, and click Insert DevExpress MVC Extension...

The Insert DevExpress Extension wizard opens. Navigate to the tab with the Data extensions and select PivotGrid. Define the extension name and the partial view name. In the Model Class item, select the data model class; in the Data Context Class item, select the data context class and select the fields you want to add to the PivotGrid.

Click the "Insert" button and the PivotGrid will be added into your project. See this topic to learn more about the MVC Wizard: Insert DevExpress MVC Extension Wizard.

After these manipulations, Insert Extension Wizard generates a partial view with the PivotGrid's settings and inserts necessary code into the corresponding controller class. As a result you have a fully functional MVC PivotGrid bound to a data source using the Entity Framework.

Is this topic helpful?​​​​​​​