Topic
  • 144 replies
  • Latest Post - ‏2019-04-12T15:00:41Z by MitchBucanon
vish2017
vish2017
47 Posts

Pinned topic IBM Data Server Provider support for .NET Core

‏2017-02-15T06:32:31Z | .net core ibm

We are pleased to announce the Beta support for IBM Data Server Provider for .NET Core. IBM Data Server Providers ( Beta) for .NET Core is available at NuGet :
For Windows
      https://www.nuget.org/packages/IBM.Data.DB2.Core/1.0.0.100
      https://www.nuget.org/packages/IBM.EntityFrameworkCore/1.0.0.100

and for Linux
     https://www.nuget.org/packages/IBM.Data.DB2.Core-lnx/1.0.0.100
     https://www.nuget.org/packages/IBM.EntityFrameworkCore-lnx/1.0.0.100

 

For more details please refer to the following link:
https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/DB2DotnetCore?lang=en

Updated on 2017-06-21T15:23:10Z at 2017-06-21T15:23:10Z by vish2017
  • vish2017
    vish2017
    47 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-06-23T05:23:03Z  

    We have released an updated version of IBM Data Server Provider for .NET Core. The NuGet package is available for download at :
    For Windows:
          https://www.nuget.org/packages/IBM.Data.DB2.Core/1.1.1.101
          https://www.nuget.org/packages/IBM.EntityFrameworkCore/1.1.1.101
    and for Linux
          https://www.nuget.org/packages/IBM.Data.DB2.Core-lnx/1.1.1.101
          https://www.nuget.org/packages/IBM.EntityFrameworkCore-lnx/1.1.1.101

     

    The details in the following link are also updated to indicate the enhancements available in this release
    https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/DB2DotnetCore?lang=en

  • kochm
    kochm
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-06-30T14:12:54Z  

    I am having a problem when I try to connect and run a query using this package. I always get the same error:

    System.FormatException: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'
    

    Here's the code for the DbContext, taken from the articles on creating sample applications:

    public class DBDataContext : DbContext
    {
            private string DBConnectionString = "Server=XXXX;Database=XXXX;password=XXXX;userid=XXXX;";
    
            public DBDataContext() : base()
            {
    
            }
    
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                    optionsBuilder
                            .UseDb2(DBConnectionString, 
                                    p => p.SetServerInfo(IBMDBServerType.OS390, IBMDBServerVersion.OS390_11_01));
            }
    
            public virtual DbSet<Results> Results { get; set; }
    }
    
  • kochm
    kochm
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-06-30T19:15:57Z  
    • kochm
    • ‏2017-06-30T14:12:54Z

    I am having a problem when I try to connect and run a query using this package. I always get the same error:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">System.FormatException: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.' </pre>

    Here's the code for the DbContext, taken from the articles on creating sample applications:

    <pre class="html dw" data-editor-lang="js" data-pbcklang="html" dir="ltr">public class DBDataContext : DbContext { private string DBConnectionString = "Server=XXXX;Database=XXXX;password=XXXX;userid=XXXX;"; public DBDataContext() : base() { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseDb2(DBConnectionString, p => p.SetServerInfo(IBMDBServerType.OS390, IBMDBServerVersion.OS390_11_01)); } public virtual DbSet<Results> Results { get; set; } } </pre>

    It turns out that I had a driver installed on my machine which I removed. Afterwards, the connection attempt succeeded but then failed due to the following error:

     

    Message "ERROR [42968] [IBM] SQL1598N  An attempt to connect to the database server failed because of a licensing problem. 
    

     

    Do we need a license to connect to DB2 databases? I thought this was a free package?

  • thibas
    thibas
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-06-30T19:41:10Z  

    I was getting the same index error, and I was able to handle it by changing the order of paths on PATH environment variable. The path to nugget package needs to be prior to the other DB2 paths. Thus, you don't need to uninstall others DB2 drivers (I'm also had other drive installed on my machine).

  • kochm
    kochm
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-06T18:24:56Z  
    • thibas
    • ‏2017-06-30T19:41:10Z

    I was getting the same index error, and I was able to handle it by changing the order of paths on PATH environment variable. The path to nugget package needs to be prior to the other DB2 paths. Thus, you don't need to uninstall others DB2 drivers (I'm also had other drive installed on my machine).

    @thibas - Can you elaborate a bit more? I tried moving the path to the NUGET package to the front of my PATH variable, but that didn't change the error for me.​

  • VigneshPrasadV
    VigneshPrasadV
    7 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-19T10:22:22Z  

    How to set server type and version while not using dbcontext? If I call without server type and version, I am getting 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'

    Code:

    var connectionString = "Server=---:----;Database=---;userid=---;password=-----";
    using (DB2Connection conn = new DB2Connection(connectionString))
    {
    conn.Open(); // here I get the about exception

    ....

    }

  • Archanaibm
    Archanaibm
    40 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-19T10:45:44Z  

    How to set server type and version while not using dbcontext? If I call without server type and version, I am getting 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'

    Code:

    var connectionString = "Server=---:----;Database=---;userid=---;password=-----";
    using (DB2Connection conn = new DB2Connection(connectionString))
    {
    conn.Open(); // here I get the about exception

    ....

    }

    Hi,

    Setting Server type info is mandatory only for EF applications.  For .Net Runtime application we do not need to pass this info.

    Have you set correct CLI driver path ? What is the output of db2level ?

     

    Thanks & Regards,

    Archana

  • VigneshPrasadV
    VigneshPrasadV
    7 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-24T07:23:26Z  

    Hi,

    Setting Server type info is mandatory only for EF applications.  For .Net Runtime application we do not need to pass this info.

    Have you set correct CLI driver path ? What is the output of db2level ?

     

    Thanks & Regards,

    Archana

    Yes, I did. Now I have deleted the older version of NuGet. But getting ERROR [42968] [IBM] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968 

    The license is placed in .nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver\license as mentioned in this link.

    Note: The same license works for 1.0.0.100

  • Archanaibm
    Archanaibm
    40 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-24T08:23:02Z  

    Yes, I did. Now I have deleted the older version of NuGet. But getting ERROR [42968] [IBM] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968 

    The license is placed in .nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver\license as mentioned in this link.

    Note: The same license works for 1.0.0.100

    Old license will not work as that would be for 10.5 release. You need to get 11.1 License.
     

  • VigneshPrasadV
    VigneshPrasadV
    7 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-25T08:57:53Z  

    Old license will not work as that would be for 10.5 release. You need to get 11.1 License.
     

    Hi,

    What would be the procedure to get 11.1 license? It would really be helpful if you could provide some link.

    Thanks, 

    Vignesh

  • Archanaibm
    Archanaibm
    40 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-26T07:13:42Z  

    Hi,

    What would be the procedure to get 11.1 license? It would really be helpful if you could provide some link.

    Thanks, 

    Vignesh

    Hi,

    We've shared instructions in a file, Please let us know if you got an email.

     

    Regards,

    Archana

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-27T12:20:55Z  
    • thibas
    • ‏2017-06-30T19:41:10Z

    I was getting the same index error, and I was able to handle it by changing the order of paths on PATH environment variable. The path to nugget package needs to be prior to the other DB2 paths. Thus, you don't need to uninstall others DB2 drivers (I'm also had other drive installed on my machine).

    Still I am getting same error, could you please assist me for this.

    startup.cs file code

    services.AddDbContext<SampleContext>(options => options.UseDb2(Configuration.GetConnectionString("ConnectionStringName"),
                    p => p.SetServerInfo(IBMDBServerType.LUW, IBMDBServerVersion.LUW_11_01_1010)));

    Connection String

    "DATABASE=<DBName>SERVER=<server name>:<Port no>;UID=<user name>;PWD=<Pass>;"

    DB Connection code:
    var db = _SampleContext.Database.GetDbConnection();
    if (db.State != ConnectionState.Open)
                            db.Open();

    Modified PATH environment location :

    C:\Users\UserName\.nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver\bin

    Used Nuget packages

    "IBM.EntityFrameworkCore": "1.1.1.101",
    "Microsoft.EntityFrameworkCore": "1.1.2",
    "Microsoft.EntityFrameworkCore.Relational": "1.1.2",
    "NETStandard.Library": "1.6.1",
    "System.Data.Common": "4.3.0"

     

     

  • thibas
    thibas
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-27T21:50:48Z  
    • kochm
    • ‏2017-07-06T18:24:56Z

    @thibas - Can you elaborate a bit more? I tried moving the path to the NUGET package to the front of my PATH variable, but that didn't change the error for me.​

    @kochm, Sorry for the delayed message.

    If I'm not mistaken, a coworker of mine had moved the NuGet path to the first position of PATH and that didn't solve the problem. I think you need to move to the last position just before to other DB2 paths. That worked for me. Remember that you need to restart Visual Studio after update the PATH environment variable.

  • thibas
    thibas
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-27T21:56:21Z  
    • thibas
    • ‏2017-07-27T21:50:48Z

    @kochm, Sorry for the delayed message.

    If I'm not mistaken, a coworker of mine had moved the NuGet path to the first position of PATH and that didn't solve the problem. I think you need to move to the last position just before to other DB2 paths. That worked for me. Remember that you need to restart Visual Studio after update the PATH environment variable.

    @onkarw210, see my answer to @kochm just above. Maybe it could help you. I'm not using EF on my project.

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T05:28:16Z  
    • thibas
    • ‏2017-07-27T21:56:21Z

    @onkarw210, see my answer to @kochm just above. Maybe it could help you. I'm not using EF on my project.

    Thanks for the response 

    We have to change system variables or user specific variables?

    From below screenshots which one (yellow or red?), I have changed Yellow one

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T07:35:11Z  
    • kochm
    • ‏2017-06-30T19:15:57Z

    It turns out that I had a driver installed on my machine which I removed. Afterwards, the connection attempt succeeded but then failed due to the following error:

     

    <pre class="html dw" data-editor-lang="js" data-pbcklang="html" dir="ltr">Message "ERROR [42968] [IBM] SQL1598N An attempt to connect to the database server failed because of a licensing problem. </pre>

     

    Do we need a license to connect to DB2 databases? I thought this was a free package?

    Hi

    Are able to solve this issue, If yes could you please assist me for this. because i am also getting same error

  • PrashanthRaoK
    PrashanthRaoK
    66 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T07:50:36Z  
    • onkarw210
    • ‏2017-07-28T05:28:16Z

    Thanks for the response 

    We have to change system variables or user specific variables?

    From below screenshots which one (yellow or red?), I have changed Yellow one

    Hi ,

     

    Please open a Visual Studio Command Prompt and execute "db2level" .

    The command output will show from which path the driver is getting loaded.

     

    Ex:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0>db2level

    DB21085I  This instance or install (instance name, where applicable: "*") uses
    "64" bits and DB2 code release "SQL11012" with level identifier "0203010F".
    Informational tokens are "DB2 v11.1.2020.1393", "s1706091900",
    "DYN1701310100WIN64", and Fix Pack "2".
    Product is installed at
    "C:\Users\<user_name>\.nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver"

    with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI".


    C:\Program Files (x86)\Microsoft Visual Studio 14.0>

     

    If you see the path to the previous version of drivers, just take a back up of both User and System Environment variable.

    Delete any references to previous driver versions and keep reference to only the driver which want to use.

     

    Open a new command prompt and try the "db2level" command and you must see the exact path of the driver you wanted to use.

     

    Now run the application and it will pick up the new driver.

     

    Thanks and Regards,

    Prashanth.

  • PrashanthRaoK
    PrashanthRaoK
    66 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T08:10:59Z  

    Hi ,

     

    Please open a Visual Studio Command Prompt and execute "db2level" .

    The command output will show from which path the driver is getting loaded.

     

    Ex:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0>db2level

    DB21085I  This instance or install (instance name, where applicable: "*") uses
    "64" bits and DB2 code release "SQL11012" with level identifier "0203010F".
    Informational tokens are "DB2 v11.1.2020.1393", "s1706091900",
    "DYN1701310100WIN64", and Fix Pack "2".
    Product is installed at
    "C:\Users\<user_name>\.nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver"

    with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI".


    C:\Program Files (x86)\Microsoft Visual Studio 14.0>

     

    If you see the path to the previous version of drivers, just take a back up of both User and System Environment variable.

    Delete any references to previous driver versions and keep reference to only the driver which want to use.

     

    Open a new command prompt and try the "db2level" command and you must see the exact path of the driver you wanted to use.

     

    Now run the application and it will pick up the new driver.

     

    Thanks and Regards,

    Prashanth.

    Hi ,

     

    You need to have a V11.1 license for this driver to work.

     

    We have emailed you the instructions for getting the trial license.

     

    Thanks and Regards,

    Prashanth.

     

     

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T08:17:19Z  

    Hi ,

     

    Please open a Visual Studio Command Prompt and execute "db2level" .

    The command output will show from which path the driver is getting loaded.

     

    Ex:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0>db2level

    DB21085I  This instance or install (instance name, where applicable: "*") uses
    "64" bits and DB2 code release "SQL11012" with level identifier "0203010F".
    Informational tokens are "DB2 v11.1.2020.1393", "s1706091900",
    "DYN1701310100WIN64", and Fix Pack "2".
    Product is installed at
    "C:\Users\<user_name>\.nuget\packages\IBM.Data.DB2.Core\1.1.1.101\build\clidriver"

    with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI".


    C:\Program Files (x86)\Microsoft Visual Studio 14.0>

     

    If you see the path to the previous version of drivers, just take a back up of both User and System Environment variable.

    Delete any references to previous driver versions and keep reference to only the driver which want to use.

     

    Open a new command prompt and try the "db2level" command and you must see the exact path of the driver you wanted to use.

     

    Now run the application and it will pick up the new driver.

     

    Thanks and Regards,

    Prashanth.

    Thanks for the response.

    I am also able to see the same output which you shown but still facing error. Even I am having IBM DB2 license version (9.7.6)

    Could you please assist me where is the exact license file location ? so that I can copy this file.

     

    Updated on 2017-07-28T08:18:53Z at 2017-07-28T08:18:53Z by onkarw210
  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T10:05:31Z  

    Hi ,

     

    You need to have a V11.1 license for this driver to work.

     

    We have emailed you the instructions for getting the trial license.

     

    Thanks and Regards,

    Prashanth.

     

     

    Hi Prashanth,

    Any update on this?

  • PrashanthRaoK
    PrashanthRaoK
    66 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T11:07:11Z  
    • onkarw210
    • ‏2017-07-28T10:05:31Z

    Hi Prashanth,

    Any update on this?

    Hi Onkar,

    You need to have V11.1 license.

     

    Please follow the instructions mentioned in the email.

     

    Once you obtain the license, please follow the FAQ link to know how to apply the license.

     

    Thanks,

    Prashanth.

     

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T11:17:17Z  

    Hi Onkar,

    You need to have V11.1 license.

     

    Please follow the instructions mentioned in the email.

     

    Once you obtain the license, please follow the FAQ link to know how to apply the license.

     

    Thanks,

    Prashanth.

     

    Hi Prashanth,

     

    As per 4th answer of FAQ we have to copy license file from installed folder to nuget folder.

    In my case I am  having license copy of IBM DB2 Client (9.7.6) but I don't have that .lic file.

    So i wanted to know that what will be the location of .lic file.

    And it is working fine with Asp.net framework (Using IBM.Data.DB2 dll) but facing error with .Net core framework (IBM.Data,DB2.Core package).

    And is this only work with V11.1 because i am having DB2 9.7.6?

     

    Thanks.

    Updated on 2017-07-28T11:36:16Z at 2017-07-28T11:36:16Z by onkarw210
  • thibas
    thibas
    4 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-28T20:19:16Z  
    • onkarw210
    • ‏2017-07-28T05:28:16Z

    Thanks for the response 

    We have to change system variables or user specific variables?

    From below screenshots which one (yellow or red?), I have changed Yellow one

    Hi,

    I've only changed the system PATH variable (the red one).

    The error you are getting is the one starting with "Invalid index (zero based) [...]"?

  • onkarw210
    onkarw210
    14 Posts

    Re: IBM Data Server Provider support for .NET Core

    ‏2017-07-31T03:57:21Z  
    • thibas
    • ‏2017-07-28T20:19:16Z

    Hi,

    I've only changed the system PATH variable (the red one).

    The error you are getting is the one starting with "Invalid index (zero based) [...]"?

    Thanks,

    I have changed this path (Red one) and "Invalid index (zero based..." got resolved.

    But now I am getting below error

    ERROR [42968] [IBM] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.

    Do you have any solutions on this?