System.InvalidOperation No ConectionString Name DynamicReportDemoEntity Could be found in app config in console App of .Net



  • I am trying to generate pdf from dynamically from the database which is sqlserver.
    i am using the entityframework
    But
    when i am clicking on report after all code done its telling like System.InvalidOperation No ConectionString Name DynamicReportDemoEntity Could be found in app config

    this is the error screen shot
    0_1505064440393_upload-6237d1d2-6bab-4d20-8577-972276d1d95f

    ============================================
    this is my ReportingStartupCode

    public class ReportingStartup
    {
    public void Configure(IVSReportingConfiguration configuration)
    {
    //var connectionString = ConfigurationManager.ConnectionStrings["ReportsDBEntities"].ConnectionString;
    // ReportsDBEntities db = new ReportsDBEntities(@"server=pranjal;database=ADO;uid=sa;password=123;");
    var db = new DynamicReprtDemoEntities(@"data source=pranjal;initial catalog=DynamicReprtDemo;user id=sa;password=123;MultipleActiveResultSets=True;App=EntityFramework"");
    var data = db.GetData();

            configuration.RegisterSampleData("dynamic", db.GetData());
    
        }
    }
    

    =======================================

    This is my MainMethode Code
    class Program
    {
    static void Main(string[] args)
    {
    IEmbeddedReportingServer embeddedServer = new EmbeddedReportingServer() ;
    embeddedServer.StartAsync().Wait();
    embeddedServer.ReportingService.SynchronizeTemplatesAsync().Wait();
    var result = embeddedServer.ReportingService.RenderAsync("Report1", new
    {
    template = new Template()
    {
    content = "<table><tr><td>Hello World</td></tr></table>",
    }
    }).Result;
    using (var fs = File.Create(@"f:\pdf\pranjal.pdf"))
    {
    result.Content.CopyTo(fs);
    }

        }
    

    =====================================================

    This is my contextclass code

    public partial class DynamicReprtDemoEntities : DbContext
    {
    public DynamicReprtDemoEntities(string Name)
    : base("name=DynamicReprtDemoEntities")
    {
    }
    public DynamicReprtDemoEntities() { }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
        public virtual DbSet<Department> Departments { get; set; }
        public object GetData()
        {
    
            return new
            {
                Departments = Departments.Include(d => d.Dept).Select(d => new
                {
                    Id = d.ID,
                    Name = d.Name,
                    Department = d.Dept,
                    Company = d.Company
                }).ToList()
            };
        }
    }
    

    ====================================
    connection string present under the config file please see

    <connectionStrings>
    <add name="DynamicReprtDemoEntities" connectionString="metadata=res:///MyDataBase.csdl|res:///MyDataBase.ssdl|res://*/MyDataBase.msl;provider=System.Data.SqlClient;provider connection string="data source=pranjal;initial catalog=DynamicReprtDemo;user id=sa;password=123;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
    </connectionStrings>



  • while clicking on student.jsrep report for dynamically binding the data before open the vs tool for jsreport i am getting this error i want to bind the data dynamically from sampale data which defing in reportingStartup please help i not getting



  • Any reason why not to try the approach from the .NET jsreport sdk v2? As I've mentioned in the other your topic. The VS extension as well as jsreport.Embedded is not up to date. I strongly recommend to try the better approach implemented in v2.

    https://jsreport.net/learn/dotnet
    https://www.youtube.com/watch?v=qqTGQgkEHow



  • For you question... you cannot use ConfigurationManager in the ReportingStartup.cs. The reason is that the context of ReportingStartup.cs is loaded by reflection, not as the full project start.
    See how the connection string is specified in the example
    https://github.com/jsreport/net/blob/master/examples/ContosoUniversity/ContosoUniversity/ReportingStartup.cs#L16



  • i also used the asp .net but getting same error please help me i have demo of jsreport.
    i be working on payroll project and we are planning to generate the pdf from this.
    i generated the static report but the problem with dynamic.



  • still getting same error no luck i changed the code which you mentioned in link
    var db = new DynamicReprtDemoEntities("Data Source=pranjal;Initial Catalog=DynamicReprtDemo;Integrated Security=SSPI;");

            //var data = db.GetData();
            
            configuration.RegisterSampleData("dynamic", db.GetData());

Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.