Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core IBM DB2 Core:ASP.NET Core 2.1和Microsoft企业库的连接字符串_Asp.net Core_Db2_Connection String_Enterprise Library_Enterprise Library 6 - Fatal编程技术网

Asp.net core IBM DB2 Core:ASP.NET Core 2.1和Microsoft企业库的连接字符串

Asp.net core IBM DB2 Core:ASP.NET Core 2.1和Microsoft企业库的连接字符串,asp.net-core,db2,connection-string,enterprise-library,enterprise-library-6,Asp.net Core,Db2,Connection String,Enterprise Library,Enterprise Library 6,我正在为.Net Core使用Microsoft.EnterpriseLibrary端口。它需要一个配置文件app.config,其中包含指定的连接字符串。我尝试使用在另一个工作项目中使用的相同连接字符串,但在这里不起作用 如何为ASP.NET Core 2.1指定DB2连接字符串 我试过这样做: 但当我执行此命令时: DatabaseFactory.SetDatabaseProviderFactory 新的DatabaseProviderFactory 新建SystemConfiguratio

我正在为.Net Core使用Microsoft.EnterpriseLibrary端口。它需要一个配置文件app.config,其中包含指定的连接字符串。我尝试使用在另一个工作项目中使用的相同连接字符串,但在这里不起作用

如何为ASP.NET Core 2.1指定DB2连接字符串

我试过这样做:

但当我执行此命令时:

DatabaseFactory.SetDatabaseProviderFactory 新的DatabaseProviderFactory 新建SystemConfigurationSourcefalse.GetSection , 错误的 ; var db=DatabaseFactory.CreateDatabaseDevelopment; 这给我带来了一个例外:

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.

我认为提供商名称不正确,但我在网上找不到任何可用的示例。

好的,我解决了它。事实证明,我找不到IBM.Data.DB2.Core的任何提供程序,因此我将app.config文件配置为:


在探索IBM程序集时,我发现有一个名为DB2Factory的DbProviderFactory实现类。如果app.config文件配置了如上所示的system.data节,则可以使用该类作为提供程序名称。

您是否尝试阅读文档?具体而言,[此页]上的链接1和2分别显示正确的提供程序名称和连接字符串属性。@mustaccio这些文章是关于.NET Framework的,而不是关于.NET Core的。无论如何,我尝试了他们建议的提供程序名称IBM.Data.DB2,但它无论如何都不起作用。