This is a migrated thread and some comments may be shown as answers.

Configure Entity Data Source - Choose a context is empty

2 Answers 311 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Darryl
Top achievements
Rank 1
Darryl asked on 17 Jun 2015, 05:48 PM

VS2013, Telerik Reporting Q1 2015, EF 6

I'm attempting my first Telerik Report, but I'm running into a pretty big stumbling point. I have an MVC 5 web app and a separate project with my EF code first data objects. Now I've added a Telerik Reporting project and I'm attempting to create some reports using the entity objects. I added a project reference to my data project - I'm not sure if this is necessary and it shows a small yellow triangle on the reference for some reason.

While creating a new report I choose to use an Entity Data Source. I'm presented with the connection strings it finds in web.config from my web app so I choose the one I'd like to use. On the next screen where it's asking me to choose a context (DbContext or ObjectContext) the box that's supposed to list my contexts is completely empty.

I'm stumped. I guess I could go back to the stand alone report designer and just use SQL to build my reports, but I really want to be able to manipulate the data and do my data selection for my report in code since I already have all my nice POCOs and relationships all built with EF. Is there a good, complete, end-to-end walkthrough for this? There are bits and pieces of documentation, but I haven't found anything that is a complete example all in one place.

2 Answers, 1 is accepted

Sort by
0
Darryl
Top achievements
Rank 1
answered on 17 Jun 2015, 05:57 PM

I figured out why the reference showed a yellow triangle. The target framework for the Reporting project was 4.0, but the Data project is targeting 4.5.1. Once I changed the Reporting project to target 4.5.1 the reference to the Data project is fine. However, now I get an error when I get to the "Choose a context" screen:

An unexpected error has occurred.

Error Message: GenericArguments[0], 'FleetReservations.Data.FRContext' on 'System.data.Entity.Migrations.DbMigrationsConfiguration`1[TContext]' violates the constraint of type 'TContext'.

0
Stef
Telerik team
answered on 19 Jun 2015, 03:23 PM
Hi Darryl,

In your case there is an error coming from the attempt to load the created data model. The following suggestions are related to the following known issues:
  1. If the EntityDataSource cannot pass its connection string to the model, the configuring of the component will fail - adding a second constructor based on EntityDataSource overview must prevent this;

  2. If the Entity Data Model is built with one version of EF, and you are referencing other EF assemblies, the model may fail to be loaded. - update of packages through Nuget and proper binding redirects should resolve this issue;

  3. If the EF model is built in an external assembly and loaded in VS Report Designer, the assembly might be locked and loaded multiple times, which can bring conflicts on loading the data in the Report Designer and the data source wizard. This issue is out of our control and is caused by the way Visual Studio loads assemblies. - test extending the Standalone Designer tool to load the external assembly and configuring the EntityDataSource component will show if this is the case. Also the test with displaying in a viewer an already designed report bound to the model allows us to detect if the problem is related .

    To use the Standalone Report Designer you will have to add both your assemblies and the EF assemblies to the config file of the Designer. For more information please check the Extending Report Designer help article. In your case the xml will look something like this:
    <Telerik.Reporting>
       <AssemblyReferences>
           <add name="MyCustomAssembly" version="1.0.0.0" culture="neutral" publicKeyToken="null" />
           <add name="EntityFramework" version="6.0.0.0" culture="neutral" publicKeyToken="..." />
           <add name="EntityFramework.SqlServer" version="6.0.0.0" culture="neutral" publicKeyToken="..." />
       </AssemblyReferences>
    </Telerik.Reporting>

    The config file is situated in the same folder as the exe file of the Designer, which is usually C:\Program Files (x86)\Telerik\Reporting Q1 2015\Report Designer. Ready reports can be imported in VS Report Designer, deserialized or deployed without modification (Deploying trdx (XML report definition) that uses external assembly).

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Darryl
Top achievements
Rank 1
Answers by
Darryl
Top achievements
Rank 1
Stef
Telerik team
Share this question
or