The requested page is not available for the requested platform. You are viewing the content for Default platform.

Bind a Report to an Entity Framework Data Source

This document describes how to use an Entity Framework data source to bind a report to data provided by an Entity Framework data context at design time within Visual Studio.

To bind a report to an Entity Framework data context, do the following.

  1. Click the report's smart tag. In the invoked actions list, expand the drop-down menu for the DataSource property and click Add Report Data Source...

    how-to-ef-datasource01

  2. On the first page of the invoked Data Source Wizard, select the Entity Framework and click Next.

    ReportWizard-SelectDataSourceType-EntityFramework

  3. On the next page, select the required data context. You can bind it to an Entity Framework data context that is contained in either the current project assembly or a separate assembly.

    To use a data context that exists in the current project assembly, select it in the Choose Context list and click Next.

    how-to-ef-datasource03

    Select the required data context and click Next.

  4. On the next page, specify a connection string to be used to establish a data connection using one of the following two options.

    • Use an existing connection string available in the current project. To do this, select Yes, let me choose from the list. Next, select the required connection string from the list of the available connection strings.

      how-to-ef-datasource05

    • Specify a connection string manually. To do this, select No, specify a custom connection string and click Next. On the next page, specify a connection string. You can choose to use the default connection string if it is specified in the application's configuration file, or specify a custom connection string (and choose whether or not to store it in the application's configuration file).

      how-to-ef-datasource-specify-connection-string

      See Connection Strings in the ADO.NET Entity Framework for more information.

  5. The next wizard page is available only if the current entity data model contains stored procedures. This page allows you to add stored procedures to the data source and configure their parameters. For more information, refer to the following document: Bind a Report to an Entity Framework Stored Procedure. Click Finish to exit the wizard.

    how-to-ef-datasource06

    The newly created data source will be displayed in the Components node of the Report Explorer. Additionally, the hierarchy of the data source will be reflected by the Field List.

    how-to-ef-datasource07

See Also