Topic
11 replies Latest Post - ‏2013-08-06T09:54:12Z by Arvind_Gupta
PhaniKrishnaV
PhaniKrishnaV
21 Posts
ACCEPTED ANSWER

Pinned topic ADO.Net Informix Enitty Framework

‏2013-07-23T06:07:11Z |

I am trying to use Entity Framework with Informix database. 

Configured DRDA port and installed IBM DB2 dataserver client and tested the connection using "testconn40.exe". It worked fine without any issues.

When I try to connect through entity framework, getting below error:

No Entity Framework provider found for 'IBM.Data.DB2' ADO.NET provider. 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.

Here is entry from machine.config file.

<DbProviderFactories>
      <add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
     
    </DbProviderFactories>

 

It's been 15 days since i started entity framework and informix. Still facing issues in set up itself.

 

Any help would be great help.

 

Thanks,

Phani

  • Arvind_Gupta
    Arvind_Gupta
    50 Posts
    ACCEPTED ANSWER

    Re: ADO.Net Informix Enitty Framework

    ‏2013-07-23T07:00:02Z  in response to PhaniKrishnaV

    Hi Phani,

    By going thru the error description, it seems IBM.Data.DB2.Entity.dll is not present in GAC.  Was IBM.Data.DB2.Entity.dll removed from GAC manually?

    Please check whether IBM.Data.DB2.Entity.dll is present in your install directory.
    <INSTALLDIR>\bin\netf40\IBM.Data.DB2.Entity.dll
    And in below location if your have 64-bit machine and installed 64-bit version of  IBM Data Server client.
    <INSTALLDIR>\bin\netf40_32\IBM.Data.DB2.Entity.dll

    If IBM.Data.DB2.Entity.dll present in your install directory, Please add it to GAC manually using Gacutil and try again. Let us know if this helps.

    Thanks & Regards,
    Arvind
     

    • PhaniKrishnaV
      PhaniKrishnaV
      21 Posts
      ACCEPTED ANSWER

      Re: ADO.Net Informix Enitty Framework

      ‏2013-07-23T13:46:17Z  in response to Arvind_Gupta

      Thank you for reply Arvind.

      I have checked GAC (assembly folder) it has all IBM.Data.DB2 dlls. (C:Windows\Microsoft.Net\Assembly\GAC_32 and GAC_64.

      And it's version is 9.7.5.4.

      And when i tried small program with suing DB2Connection and DB2Command to access database, it worked fine.

      Any other thoughts please.

       

      Regards,

      Phani

       

       

      • Arvind_Gupta
        Arvind_Gupta
        50 Posts
        ACCEPTED ANSWER

        Re: ADO.Net Informix Enitty Framework

        ‏2013-07-23T14:51:58Z  in response to PhaniKrishnaV

        Hi Phani,

        Please note that I mentioned for IBM.Data.DB2.Entity.dll.

        If it is not present in GAC, you will need to add it to GAC by using Gacutil utility.

        Thanks,

        Arvind

         

        • PhaniKrishnaV
          PhaniKrishnaV
          21 Posts
          ACCEPTED ANSWER

          Re: ADO.Net Informix Enitty Framework

          ‏2013-07-23T15:04:33Z  in response to Arvind_Gupta

          Hi Arvind,

          I have checked for IBM.Data.DB2.Entity.dll. It is present in GAC.

          Thanks

          Phani

          • Arvind_Gupta
            Arvind_Gupta
            50 Posts
            ACCEPTED ANSWER

            Re: ADO.Net Informix Enitty Framework

            ‏2013-07-23T15:36:37Z  in response to PhaniKrishnaV

            Could you please capture and share step by step screen shots, it will help to give us more information to help you out.

            • PhaniKrishnaV
              PhaniKrishnaV
              21 Posts
              ACCEPTED ANSWER

              Re: ADO.Net Informix Enitty Framework

              ‏2013-07-23T17:04:22Z  in response to Arvind_Gupta

              1)      After installation of VS 2012

              2)      DB Server Client (v 9.7.5)- This installed in C:\Program Files\ibm\SQLLIB folder

              3)      Didn't have VS 2012 DB2 add-ins, as I can't install them in Client environment and I guess these are not mandatory.

              4)      Tested the connection using:

              C:\Program Files\ibm\SQLLIB\BIN>testconn40.exe Database=supplierportal;UserID=informix;password=*****;Server=server:12504;

              C:\Program Files\IBM\SQLLIB\BIN>testconn40.exe server=servername:12345;database=SupplierPortal; userid

              =informix;password=*****;

              Step 1: Printing version info

                      .NET Framework version: 4.0.30319.17929
                     64-bit

                      DB2 .NET provider version: 9.7.4.4
                      DB2 .NET file version: 9.7.5.4
                      Capability bits: ALLDEFINED
                      Build: 20111018
                      Factory for invariant name IBM.Data.DB2 verified
                      Factory for invariant name IBM.Data.Informix verified
                      IBM.Data.Informix from DbFactory is the Common Informix .NET provider
                      Elapsed: 1.5468552

              Step 2: Validating db2dsdriver.cfg against db2dsdriver.xsd schema file
                      File C:\ProgramData\IBM\DB2\DB2COPY1\cfg\db2dsdriver.cfg  missing. Nothing to validate
                      Elapsed: 0.0156248

               

              Step 3: Connecting using "server=servername:12345;database=SupplierPortal;userid=informix;password=*****"
                      Server type and version: IDS 11.50.0000
                      Elapsed: 1.6249792

              Step 4: Selecting rows from informix.systables to validate existence of packages
                 SELECT * FROM informix.systables
                      Elapsed: 0.3437456
              Step 5: Calling GetSchema for tables to validate existence of schema functions
                      Elapsed: 0.5937424

              Test passed.

              5)      Created small solution to  test with entity framework:

              Here is important classes:

              DbContext:

                  public partial class SupplierPortalContext : DbContext

                  {

                      staticSupplierPortalContext()

                      {           

                          Database.SetInitializer<SupplierPortalContext>(null);

                      }

               

                      publicSupplierPortalContext()

                          : base("Name=SupplierPortalConnection")

                      {

                      }

               

                      public DbSet<Pouch> Pouches { get; set; }

               

                      protected override voidOnModelCreating(DbModelBuildermodelBuilder)

                      {

                          modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.TableAttributeConvention>();

                 

                          modelBuilder.Configurations.Add(new PouchMap());           

              }

              }

               

              Model Class:

              [Table("pouch")]

                  public partial class Pouch

                  {

                      public int PouchId { get; set; }

                      public string BookingNum { get; set; }

                  }

               

              Mapping:

              publicclass PouchMap : EntityTypeConfiguration<Pouch>

                  {

                      public PouchMap()

                      {

                          // Primary Key

                          this.HasKey(t => t.PouchId);

               

                          // Properties

                          this.Property(t => t.PouchId)

                              .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

               

                          this.Property(t => t.BookingNum)

                              .HasMaxLength(50);

               

                          // Table & Column Mappings

                          this.ToTable("Pouch");

                          this.Property(t => t.PouchId).HasColumnName("PouchId");

                          this.Property(t => t.BookingNum).HasColumnName("BookingNum");

                     }

                  }

               

              Added  below code in main function to test the connection:

              SupplierPortalContextec = new SupplierPortalContext();

              Console.WriteLine(ec.Database.Exists());

               

              Throwing below error in second line:

               

              No Entity Framework provider found for 'IBM.Data.DB2' ADO.NET provider. 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.

               

              Other details:

              DbProviderFactories section from machine.config file:

               

              64 bit

              <DbProviderFactories>

                    <add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM Informix .NET Data Provider" invariant="IBM.Data.Informix" description="IBM Informix Data Provider for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM DB2 .NET Data Provider 9.7.5" invariant="IBM.Data.DB2.9.7.5" description="IBM DB2 Data Provider 9.7.5 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.9.7.5, Version=9.7.5.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM Informix .NET Data Provider 9.7.5" invariant="IBM.Data.Informix.9.7.5" description="IBM Informix Data Provider 9.7.5 for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix.9.7.5, Version=9.7.5.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                  </DbProviderFactories>

               

              32 bit

              <DbProviderFactories>

                <add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM Informix .NET Data Provider" invariant="IBM.Data.Informix" description="IBM Informix Data Provider for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM DB2 .NET Data Provider 9.7.5" invariant="IBM.Data.DB2.9.7.5" description="IBM DB2 Data Provider 9.7.5 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.9.7.5, Version=9.7.5.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                    <add name="IBM Informix .NET Data Provider 9.7.5" invariant="IBM.Data.Informix.9.7.5" description="IBM Informix Data Provider 9.7.5 for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix.9.7.5, Version=9.7.5.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

                  </DbProviderFactories>

               

              Please find the attached DB2.dll properties from GAC.

              I hope i have given all details on this issue. Please let me know for more details that i missed if any.

              Note:

              I have used similar set up in my local machine (I have installed Informix dev server and DB client 10.* version.).

              It is working without any issues.

              Client keen on NHibernate, but we insisted on EntityFramework, but never thought of end up in this issue.

               

              I really appreciate your efforts on this issue. 

              Attachments

              Updated on 2013-07-23T19:05:40Z at 2013-07-23T19:05:40Z by PhaniKrishnaV
              • Arvind_Gupta
                Arvind_Gupta
                50 Posts
                ACCEPTED ANSWER

                Re: ADO.Net Informix Enitty Framework

                ‏2013-07-24T17:38:49Z  in response to PhaniKrishnaV

                Hi Phani,

                Thanks for providing the details.

                IBM DB2 ADO.NET provider support Database first approach at present. Hence you need to have DB2 add-ins installed.

                As you mentioned  " Didn't have VS 2012 DB2 add-ins, as I can't install them in Client environment and I guess these are not mandatory."   and looking at your code, it seems you are following code first approach that IBM DB2 ADO.NET provide does not support at present.

                You may want to take a quick look of this article to understand how to create model from existing database.

                http://www.ibm.com/developerworks/data/library/techarticle/dm-0903linqentity/#generating

                Thanks.

                Arvind

                • PhaniKrishnaV
                  PhaniKrishnaV
                  21 Posts
                  ACCEPTED ANSWER

                  Re: ADO.Net Informix Enitty Framework

                  ‏2013-08-05T02:59:45Z  in response to Arvind_Gupta

                  Hi Arvind,

                  I am using Database first approach, but using DBContext class.

                  The above problem has been solved. It was dll problem, but i have connection problem once in a while though. 

                  Thank you Arvind.

                   

                  • Arvind_Gupta
                    Arvind_Gupta
                    50 Posts
                    ACCEPTED ANSWER

                    Re: ADO.Net Informix Enitty Framework

                    ‏2013-08-05T07:05:16Z  in response to PhaniKrishnaV

                    Hi Phani,

                    Could you please elaborate more about the connection problem, e.g. when you get this error , what error do you see in   testconn40.exe output etc.

                    Also it will be more helpful if you could capture the screen shot and share it.

                    Thanks,

                    Arvind

                     

                    • PhaniKrishnaV
                      PhaniKrishnaV
                      21 Posts
                      ACCEPTED ANSWER

                      Re: ADO.Net Informix Enitty Framework

                      ‏2013-08-05T20:36:26Z  in response to Arvind_Gupta

                      HI Arvind,

                      I am getting connection problems some times, like one in 5 connections:

                      Here is the exception messages that i captured:

                      1) underlying provider failed on Open.

                      2) An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

                      The provider did not return a ProviderManifestToken string.

                      3) ERROR [40003] [IBM] CLI0108E  Communication link failure. SQLSTATE=40003

                      And for all above here is inner exception message:

                      ERROR [08001] [IBM] SQL30081N  A communication error has been detected. Communication protocol being used: "TCP/IP".  Communication API being used: "SOCKETS".  Location where the error was detected: "10.246.21.78".  Communication function detecting the error: "recv".  Protocol specific error code(s): "10060", "*", "*".  SQLSTATE=08001

                      I have tested the connection with Entity Framework and native Db2Connection.

                      In both the cases, above error has thrown.