none
design time issues RRS feed

  • Question

  • hi,

    i have some problems displaying my usercontrols with EF6 in design time

    first i had a connectionstring not found exception, so after some search i modified the dbcontext constructor to change connectionstring dynamically like this

     public partial class CardioEFEntities : DbContext
        {
            public CardioEFEntities(String connString)
            : base(connString)
            {
     
            }
    
         
        }
    .
    .
    .
    .
    .
    .
    
      string p = "metadata=res://*/CardioEFModel.csdl|res://*/CardioEFModel.ssdl|res://*/CardioEFModel.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string='character set=ISO8859_1;data source=localhost;initial catalog=C:\\Dev\\WPF\\Projects\\Cardio\\CARDIO.FDB;user id=SYSDBA;password=masterkey'";
                    p = p.Replace("localhost", arr[0]);
                     p = p.Replace("C:\\Dev\\WPF\\Projects\\Cardio\\CARDIO.FDB", arr[1]);
                    context = new CardioEFEntities(p);

    now i have a blank empty page instead of the exception !

    i would say that everything work at runtime fine but not in design time,

    also i have my DAL in a separate class library project .

    any help is welcome

    thanks and goo day !

    Saturday, March 21, 2015 1:09 PM

Answers

  • Hi,

    i ended up by using this solution

        if (! System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
    // get Data from Database
    else
    // get emptylist
    

    it's sort of a hack but at least it works and i don't have this error

    • Marked as answer by issam1975 Wednesday, March 25, 2015 7:45 PM
    Wednesday, March 25, 2015 7:45 PM

All replies

  • [Edit]

    Now i have another exception

    : No Entity Framework provider found for the ADO.NET provider with invariant name 'FirebirdSql.Data.FirebirdClient

    but both EFFirebird and Firebird ADO provider are present in my project and in my DAL library

    Saturday, March 21, 2015 1:46 PM
  • Hello,

    >>i would say that everything work at runtime fine but not in design time,

    This confuses me that since you says it would work at runtime but not in design time, do you mean that when at design time, it shows a blank empty page without any data, if so, this should be normal, since data would load to these data control at runtime.

    >> also i have my DAL in a separate class library project.

    It seems that you locate the .edmx file to a separate project, if so, we do not need to add an additional constructor, we need to copy the generated connection string section in the DAL app.confile to your usercontrols project app.config file.

    >> Now i have another exception

    It is not very clear how the connection string looks like in your app.config. Here is an example for a standard EF connection string: https://msdn.microsoft.com/en-us/library/vstudio/cc716756(v=vs.100).aspx.

    >> but both EFFirebird and Firebird ADO provider are present in my project and in my DAL library

    Do you mean that you have also installed the EF and ADO.NET provider for Firebird to your usercontrols project? If not, please also install it. And since you are using the EntityFramework.Firebird, I suggest that you could also post this feedback to its author: https://www.nuget.org/packages/EntityFramework.Firebird/ to check if the EntityFramework.Firebird supports such scenario usage.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 23, 2015 1:46 AM
    Moderator
  • Hi,

    yes i have installed EF and db provider both in my application and in my DAL project

    here the app.config of my app

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
      </configSections>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
      </startup>
      <entityFramework>
        <defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
        <providers>
          <provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
          <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
        </providers>
      </entityFramework>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <connectionStrings>
        <add name="CardioEntities" connectionString="metadata=res://*/CardioModel.csdl|res://*/CardioModel.ssdl|res://*/CardioModel.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string=&quot;character set=ISO8859_1;data source=localhost;initial catalog=C:\Dev\WPF\Projects\Cardio\CARDIO.FDB;user id=SYSDBA;password=masterkey&quot;" providerName="System.Data.EntityClient" />
        <add name="CardioEFEntities" connectionString="metadata=res://*/CardioEFModel.csdl|res://*/CardioEFModel.ssdl|res://*/CardioEFModel.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string=&quot;character set=ISO8859_1;data source=localhost;initial catalog=C:\Dev\WPF\Projects\Cardio\CARDIO.FDB;user id=SYSDBA;password=masterkey&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <system.data>
        <DbProviderFactories>
          <remove invariant="FirebirdSql.Data.FirebirdClient" />
          <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
          <remove invariant="System.Data.SQLite.EF6" />
          <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
        </DbProviderFactories>
      </system.data>
    <appSettings>
        <add key="AWSAccessKey" value="" />
        <add key="AWSSecretKey" value="" />
      </appSettings></configuration>

    and the app.config of my DAL project

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <entityFramework>
        <defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
          <provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
        </providers>
      </entityFramework>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.data>
        <DbProviderFactories>
          <remove invariant="FirebirdSql.Data.FirebirdClient" />
          <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
        </DbProviderFactories>
      </system.data>
      <connectionStrings>
        <add name="CardioEntities" connectionString="metadata=res://*/CardioModel.csdl|res://*/CardioModel.ssdl|res://*/CardioModel.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string=&quot;character set=ISO8859_1;data source=localhost;initial catalog=C:\Dev\WPF\Projects\Cardio\CARDIO.FDB;user id=SYSDBA;password=masterkey&quot;" providerName="System.Data.EntityClient" />
        <add name="CardioEFEntities" connectionString="metadata=res://*/CardioEFModel.csdl|res://*/CardioEFModel.ssdl|res://*/CardioEFModel.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string=&quot;character set=ISO8859_1;data source=localhost;initial catalog=C:\Dev\WPF\Projects\Cardio\CARDIO.FDB;user id=SYSDBA;password=masterkey&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
    </configuration>


    now i have again this error

    System.Data.Entity.Core.MetadataException
    Schema specified is not valid. Errors: 
    CardioEFModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'FirebirdSql.Data.FirebirdClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

    btw in my code i have a class that implement INotifyPropertyChanged wich get the data from database,

    in my usercontrol i have a reference for that class like this

    <UserControl.Resources>
       <local:ListeConsViewModel x:Key="ListeConsViewModel"/>
    </UserControl.Resources>
    
    
    <UserControl.DataContext>
        <local:ListeConsViewModel />
    </UserControl.DataContext>

    thanks for your help



    Wednesday, March 25, 2015 4:19 PM
  • Hi,

    i ended up by using this solution

        if (! System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
    // get Data from Database
    else
    // get emptylist
    

    it's sort of a hack but at least it works and i don't have this error

    • Marked as answer by issam1975 Wednesday, March 25, 2015 7:45 PM
    Wednesday, March 25, 2015 7:45 PM