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

Telerik Reporting together with MS Entity Framework

16 Answers 687 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gerald
Top achievements
Rank 1
Gerald asked on 16 Mar 2009, 04:54 PM
Hello community,

is it possible to use Telerik Reporting with Microsoft's Entity Framework? I tried it, but the report couldn't retrieve data from the database.
If it is possible could somebody give me directions how to do it or where to investigate further?

Thanks in advance and kind regards,

Gerald

16 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 20 Mar 2009, 04:13 PM
Hello Gerald,

We will need some more information about this issue. How exactly did you try to connect? If it is possible, can you send us your project or a sample project that reproduces what you are experiencing. Any other information that you consider might be helpful will be greatly appreciated as well.

I am pretty sure that you have checked out the documentation, but in case you have not then the following might be helpful:

Connecting Data to a Report

We are looking forward to hearing from you.

All the best,
Ross
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Gerald
Top achievements
Rank 1
answered on 24 Mar 2009, 08:22 AM
Hello,

after some more tries I figured out how Telerik Reporting and the MS Entity Framework work together.

Anyway, thanks for the response, Ross.

Kind regards, Gerald
0
Jason
Top achievements
Rank 1
answered on 14 Apr 2009, 06:14 PM
I need to get this to work also. How did you do it ?
0
Gerald
Top achievements
Rank 1
answered on 15 Apr 2009, 07:38 AM
Hello Hector,

I solved this programmatically. The report class got a member for the entity class which I initialized in the report's constructor. After the call to InitializeComponent() I set the DataSource for the report.

 

public partial class DataBindingReport : Telerik.Reporting.Report

 

{

 

 

    private UdbEntities _db;
    public DataBindingReport()

 

 

    {

        _db =

new UdbEntities();

 

 

         InitializeComponent();

        DataSource = _db.TodaysDailyBarsPerProduct.ToList();

    }

}

UdbEntities is my entity type.

I hope that helps,

Gerald

 

 

0
Jason
Top achievements
Rank 1
answered on 15 Apr 2009, 01:47 PM
Thanks Gerald,
I did what you put but its throwing an exception when you I hit the preview tab.

"The specified named connection is either not found in the configuration. not intended to be used with the EntityClient provider, or not valid."

I did put a app.config file in my report project.

I also noticed you initialized _db before the initializecomponent() function is called.

Hector.


0
Gerald
Top achievements
Rank 1
answered on 15 Apr 2009, 02:36 PM
Hello Hector,

if you divided your project into a class library project and a report viewer project then you will have to copy the connection string from the app.config of your library to the app.config of the report viewer.

Hope it helps,

Gerald
0
Jason
Top achievements
Rank 1
answered on 15 Apr 2009, 02:54 PM
I did that when I added the app.config file. Here is my app.config/

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
        <add name="PmasContractManagerEntities" connectionString="metadata=res://*/PmasContractManager.csdl|res://*/PmasContractManager.ssdl|res://*/PmasContractManager.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=CABAND820;Initial Catalog=PmasContractManager;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
</configuration>
0
Patrick McGouirk
Top achievements
Rank 1
answered on 15 Apr 2009, 03:14 PM
Hector,

Here is my solution at the moment since I am having the exact same issue.  Something screwy with reporting stuff appears to be preventing the the code from reading either the web.config or app.config (pending on your deployment).  I was able to get around the errors by using the EntityconnectionStringBuilder from within the code.  While I REALLY don't like this solution, it has allowed me to move beyond the errors.

            MyEntities entityContext;          
            EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
            builder.Provider = "System.Data.SqlClient";
            builder.ProviderConnectionString = @"Data Source=myServerName;Initial Catalog=myDataBase;Integrated Security=True;MultipleActiveResultSets=True";
            builder.Metadata = @"res://*/myEntityModel.csdl|res://*/myEntityModel.ssdl|res://*/myEntityModel.msl";            
            context = new myEntities(builder.ToString());

Pat

0
Jeff
Top achievements
Rank 1
answered on 19 Aug 2009, 04:46 PM
So you must have manually designed your report without the preview available?  Then how do the names come out when you have child entities?
0
fayssal el moufatich
Top achievements
Rank 1
answered on 28 Sep 2009, 01:35 PM
It seems the configuration file is read only when it is placed in a project that initiates the .NET runtime (Console app or a Win Forms app). Otherwise, the entities class should be configured manually.

Thanks for the code snippet Patrick!

0
James Reategui
Top achievements
Rank 1
answered on 09 Mar 2011, 11:41 PM
I get the same problem in the designer Preview, although once I run the app the report shows up fine.

I have my core library project seperate from the web project. All the Data layer with Entity Framework is in the Core library. I added the connection string in the web.config. When I run the app, the report is generated fine, it is only in the designer Preview function that it does not work.

Seems like the designer is broken when it tries to talk to EF. Works fine with Linq2Sql though... I keep finding EF is still not ready for production. Running the latest versions of everything to date btw.
0
ITLackey
Top achievements
Rank 1
answered on 10 May 2011, 09:33 PM
I am having the same problem as well. It appears that the Preview tab of the report designer is not able to access the EF embedded resources. I have tried several changes to the config file to attempt to resolve this with no luck. At this point it is looking like a bug in the report previewer, because like the previous poster (James), everything works fine at run time. I am running the latest of Telerik Reports and VS2010 SP1.

Any information regarding this issue is much appreciated.

Thanks!
Ian
0
Peter
Telerik team
answered on 13 May 2011, 12:30 PM
Hi ITLackey,

Currently when EntityDataSource component is used the EF Model should be located in a separate class library in order the report designer previews to work properly. This limitation is caused by Visual Studio Type.GetType and we have to further investigate the issue and undertake appropriate actions.

Please excuse us for the temporary inconvenience.

Greetings,
Peter
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Todd
Top achievements
Rank 1
answered on 04 Feb 2012, 07:18 PM
Has this issue been resolved yet?
I've been trying for entire day to use the report designer with a entitydatasource and if it isn't one problem, it's another.
I've tried with a class library project in which I get the "specifed connection is not found..." problem.
If i try it in a wpf application, I get the "source has not been specified" problem.
It seems that no matter what you do, it's not possible to design a report with preview using the entitydatasource.
Do you guys have a sample project that uses the entitydatasource (with preview) sucessfully?
0
Steve
Telerik team
answered on 06 Feb 2012, 10:10 AM
Hello Todd,

In which project is Entity Model located. Generally to use the Report Designer and Report Wizard the Entity Data Model should be located in a separate project. The connectionString to the database should be copied to the config file of the reports project for the Data Explorer and Preview to work. Any extension methods should be located in the same project as the model. Additionally in some rare cases you may have to restart Visual Studio to get this running.

Regards,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Chris
Top achievements
Rank 1
answered on 07 Mar 2012, 10:37 PM
This same exact scenario is happening to me when trying to utilize an openaccess domain context from within a report library project. For whatever reason the designer preview is not able to see into the App.config (or a Web.config file for that matter) to pull in the connection string. I have separate projects for my data layer (open access domain model), report library (class library) and an asp.net project with the report viewer, all of the references and usings are set up properly and each project has a proper config file with the connection string inside, but the preview does not work, and causes the "a connection string was referneced....but could not be resolved through web/app.config". I'm using an openaccessdatasource as my main report data source, but in a few of my custom user functions I'm using linq to query against the openaccess context in order to do some value converting. This is where the error is, when accessing the context from code behind of a report. Please let me know a proper workaround, Thanks!
Tags
General Discussions
Asked by
Gerald
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Gerald
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Patrick McGouirk
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
fayssal el moufatich
Top achievements
Rank 1
James Reategui
Top achievements
Rank 1
ITLackey
Top achievements
Rank 1
Peter
Telerik team
Todd
Top achievements
Rank 1
Steve
Telerik team
Chris
Top achievements
Rank 1
Share this question
or