Invalid Argument while scaffolding DB2 schema EF 3.1

leo del ciello 66 Reputation points
2024-05-17T07:05:32.1933333+00:00

Hello.

I am trying to scaffold a DB2 schema using the IBM.EntityFrameworkCore provider (version 3.1.0.300) on an AspNet Core 3.1 web application using EntityFramework Core 3.1.

The scaffolding command line is the following :

Scaffold-DbContext 'Provider=db2oledb;User ID=WBSPN01E;Password=SbHj876d;Default Schema=A01DB2;Initial Catalog=A01DB2;Network Transport Library=TCPIP;Host CCSID=1208;PC Code Page=1252;Network Address=svil.host.inps;Network Port=5025;Package Collection=COLDASV;DBMS Platform=DB2/MVS;Process Binary as Character=False;Units of Work=RUW;Connection Pooling=False;' IBM.EntityFrameworkCore -Schemas TEFT0 -ContextDir DbContext -OutputDir Models

I keep having an "invalid Argument" error : the stack trace is the following :

System.ArgumentException: Invalid argument

at IBM.Data.DB2.Core.DB2ConnPool.ReplaceConnectionStringParms(DB2Connection connection, String szValue, DB2ConnSettings& pSettings, DB2ConnSettingsInternal& pSettingsInternal, Boolean bAttach, Boolean pushDownStrAppended)

at IBM.Data.DB2.Core.DB2Connection.set_ConnectionString(String value)

at IBM.Data.DB2.Core.DB2Connection..ctor(String connectionString)

at IBM.EntityFrameworkCore.Scaffolding.Internal.Db2DatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)

at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, Datab ...........

Suspecting it could be due to the Connection String, I tried eliminating the Connection String arguments one by one (skipping the essential ones) but nothing has changed .

What could be the problem ?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
709 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. leo del ciello 66 Reputation points
    2024-05-17T07:26:29.47+00:00

    It seems like using a very essential connection string like :

    UID=WBSPN01E;PWD=SbHj876d;DataBase=A01DB2;Server=svil.host.inps:5025;

    the scaffolding succeeds .

    I don't know exactly which one of the arguments was causing the problem , all I can say is that I am puzzled since the connection string that gave me the error was taken from a previous application using Ado.Net on the same DB2 database which was working correctly.

    Maybe the problem is with the IBM.EntityFrameworkCore assembly which needs exactly a DB2 - like connection string.

    Anyway, problem solved .

    0 comments No comments