Friday, October 04, 2013

Creating/Running Telerik Reports in Visual Studio , in Design Time

I m using entity framework and getting the data for my Telerik report from it.
To see the reports running in the Visual Designer and avoid the error: "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.", you have to hard code your connection string into the code and use the connection string while opening the connection as below:
        public static List<Region> GetRegions()
        {
            using (Entities entities = new Entities(connStr))
            {
                entities.Connection.Open();
                return entities.Regions.ToList();
            }
        } 
This won't work:
   public static List<Region> GetRegions()
        {
            using (Entities entities = new Entities())
            {
                entities.Connection.Open();
                return entities.Regions.ToList();
            }
        } 

Its against the best practise of course but to to see your reports running from Visual Studio 
,it's worth !

No comments:

Post a Comment