New to Telerik ReportingStart a free 30-day trial

How to register a DbProviderFactory in a .NET Core project

Environment

Product Version13.0.19.314 and above
ProductProgress® Telerik® Reporting
Project Type.NET Core
Preferred LanguageC Sharp

Description

This article describes how to extend the list of the supported ADO.NET data providers in a .NET Core project.

Solution

In order to create a connection to a database, the Telerik Reporting engine uses the DbProviderFactories class. Since this class does not exist in .NET Standard 2.0, the data processing engine provides a specific class named Telerik.Reporting.Processing.Data.DbProviderFactories which exposes a few static methods that can be used to register a new DbProviderFactory instance. These methods essentially modify the internal collection of DbProviderFactory types and provider invariant names. This internal collection contains predefined entries for the most popular data providers that work out-of-the-box in .NET Core projects:

DatabaseDbProviderFactory type name
MSSQLSystem.Data.SqlClient.SqlClientFactory
SQLiteSystem.Data.SQLite.SQLiteFactory
MySqlMySql.Data.MySqlClient.MySqlClientFactory
PostgreSqlNpgsql.NpgsqlFactory
OracleOracle.ManagedDataAccess.Client.OracleClientFactory

In case this list needs to be extended with a new database provider, for example Firebird, the following line needs to be executed prior to report processing:

csharp
Telerik.Reporting.Processing.Data.DbProviderFactories.RegisterFactory("FirebirdSql.Data.FirebirdClient", FirebirdSql.Data.FirebirdClient.FirebirdClientFactory.Instance);

In case the data provider does not provide a static instance, the provider can be registered with the factory assembly qualified name:

csharp
Telerik.Reporting.Processing.Data.DbProviderFactories.RegisterFactory("FirebirdSql.Data.FirebirdClient", "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=7.0.0.0");

For web projects the recommended place to register the factory is the static constructor of the ReportsController class. For desktop projects the provider registration can be done in the report viewer initialization code.

In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support