I'm using this Microsoft.EnterpriseLibrary port for .Net Core. It requires a configuration file app.config
with the connection string specified in it. I tried using the same connection string I use in another working project, but it doesn't work here.
How can I specify a DB2 connection string for ASP.NET Core 2.1?
I this is what I have tried:
<connectionStrings>
<add name="Development" connectionString="server=MY.SERVER.COM:446;database=DBXX;user id=USERXX;password=PASSWORDXX;" providerName="IBM.Data.DB2.Core"/>
</connectionStrings>
But when I execute this:
DatabaseFactory.SetDatabaseProviderFactory(
new DatabaseProviderFactory(
new SystemConfigurationSource(false).GetSection
),
false
);
var db = DatabaseFactory.CreateDatabase("Development");
It throws me this exception:
Exception has occurred: CLR/System.InvalidOperationException
An exception of type 'System.InvalidOperationException' occurred in Microsoft.Practices.EnterpriseLibrary.Data.dll but was not handled in user code: 'The connection string for the database 'Development' does not exist or does not have a valid provider.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.Configuration.ConfigurationErrorsException : The requested database Development does not have a valid ADO.NET provider name set in the connection string.
I think the provider name is incorrect, but I can't find any working example on the web.