Using Entity Framework in SharpShooter Reports

Vitaliy Korney

Before you start, please, download and install the latest Entity Framework version.

Let’s use an existing AdventureWorks Sample database, which is available here http://msftdbprodsamples.codeplex.com/

Generate DataModel from the existing AdventureWorks database.

Database Model

Put reportManager component. Let it be reportManager1.

AdventureWorksEntities class was automatically generated and we need to pass these entities as the datasource to the report.

In order to add the entity framework datasource we need to add the following code after InitializeComponent call:

InitializeComponent();
AdventureWorksEntities entities = new AdventureWorksEntities();
reportManager1.DataSources.Add("Entity", entities);
fileReportSlot1.DesignTemplate();

After running the application we will have our datasource be available.

Put the databand and specify datasource from our Entity datasource:
Entity Framework: Select Datasource

Put the textbox in the databand and specify “value” binding for it:

Value Binding

Here is the result of our manipulations:

Entity Framework: Results

The only limitation is that we haven’t invented approach for constructing your reports in the Design Time. You may create your template in the runtime Windows Forms Designer and then use this template in the ReportManager in the design time.

March 8th, 2012

Leave a Comment