dashboard-401432-web-dashboard-integrate-dashboard-component-dashboard-backend-prepare-data-source-storage-for-the-aspnet-mvc-framework-entity-framework-data-source.md
This tutorial shows how to add the DashboardEFDataSource to an in-memory data source storage, and make it available to users. The MDF database is used as a sample.
In your application, add the NWind.mdf database to the App_Data folder from the C:\Users\Public\Documents\DevExpress Demos 25.2\Components\Data directory.
In Web.config , specify a connection string to the database.
Right-click the project and select Add | ADO.NET Entity Data Model. Set OrdersContext as a model name and select the Code First from database model type in the invoked wizard.
Select the added NWindConnectionString as a data connection for the created model.
On the next page, specify which tables and views to include in your model. In this tutorial, the data model is based on the OrderDetail table. The code below shows the generated data model:
In the dashboard configuration file (for example, DashboardConfig.cs / DashboardConfig.vb), create a public method that returns the configured dashboard’s data source storage (DataSourceInMemoryStorage) and define the EF data source.
Call the DashboardConfigurator.SetDataSourceStorage method to configure the data source storage. Use the created CreateDataSourceStorage method as the SetDataSourceStorage parameter.
The EF Data Source is now available in the Web Dashboard:
Users can bind dashboard items to data in the Web Dashboard’s UI.
The example shows how to make a set of data sources available for users in the Web Dashboard application.
View Example: How to Register Data Sources for the ASP.NET MVC Dashboard Extension