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.
Click the PivotGridControl’s smart tag and select the Items Source Wizard command.
In the invoked Items Source Configuration Wizard, select Entity Framework (EF) Core…
… and ensure the Data Sources area displays a context name.
On the next page, select the binding method.
- 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.
On the final page, specify the table and click Finish.
The PivotGridControl is now bound to the created data source.
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}}"/>