Skip to main content

Entity Framework (EF) Core

  • 2 minutes to read

The Items Source Configuration Wizard allows you to bind the PivotGridControl to an SQL database using the Entity Framework Core at design time. This topic guides you through the required steps.

Note

In this tutorial, the PivotGridControl is bound to the Sales MS SQL database. Refer to the Getting started with EF Core on .NET Framework with an Existing Database topic for details on how to generate Entity Framework models for existing SQL databases.

  1. Click the PivotGridControl’s smart tag and select the Items Source Wizard command.

    WpfPivot_ProvidingData_SmartTag

  2. In the invoked Items Source Configuration Wizard, select Entity Framework (EF) Core

    ItemsSourceWizard_EFCore_SelectTechnology

    … and ensure the Data Sources area displays a context name.

  3. On the next page, select the binding method.

    DataSourceConfigurationWizard_ADO_BindingMethod

    • Simple Binding - allows you to bind the PivotGridControl to an EF Core data source directly.
    • Manipulating Data via ICollectionView - allows you to bind the PivotGridControl to an EF Core data source using the ICollectionView component, which enables collections to have the current record management functionalities, custom sorting, filtering, and grouping. See ICollectionView Specifics for more details.

    Select Simple Binding and click Next.

  4. On the final page, specify the table and click Finish.

    ItemsSourceWizard_EFCore_Finish

  5. The PivotGridControl is now bound to the created data source.

    WpfPivot_BoundToDataSet

    You can now use the Retrieve Fields command to retrieve the available data source fields. To retrieve fields in code, use the PivotGridControl.RetrieveFields method.

    Note

    Note that the Items Source Configuration Wizard adds the created data source to window resources.

    <Window.Resources>
            <dx:EntitySimpleDataSource x:Key="EntitySimpleDataSource" ContextType="{x:Type local:SalesContext}" Path="Orders">
            </dx:EntitySimpleDataSource>
        </Window.Resources>
    

    Then, it binds the PivotGridControl to the created data source.

    <dxpg:PivotGridControl DataSource="{Binding Data, Source={StaticResource EntitySimpleDataSource}}"/>