1. Home
  2. Docs
  3. Getting Started
  4. Installation
  5. How to switch Database

How to switch Database

Dotnet Report installs with Microsoft SQL Server as the default metadata and reporting database. However, Dotnet Report fully supports other relational Databases as well, and our open-source backend and pluggable database architecture make it easy to switch to other databases such as Oracle, PostgreSQL, or MySQL.

This guide walks you through the exact steps required to change the database type and wire up the correct implementation.


Supported Database Types

Dotnet Report currently provides database connection implementations for:

  • Microsoft SQL Server (default)
  • Oracle
  • PostgreSQL
  • MySQL
  • OleDb / DB2 (via OleDb)

Each database type has its own connection implementation class, allowing Dotnet Report to generate compatible SQL at runtime.


Step 1: Change the Data Connection / Workspace Database Type

In the Dotnet Report Setup page:

  1. Navigate to Data Connections or Workspaces tab.
  2. Edit the existing connection (or create a new one)
  3. Set the Database Type to one of the following:
    • Oracle
    • PostgreSQL
    • MySQL
    • OleDb/Others
  4. Update the connection string in your appSettings.config to match your database

This tells Dotnet Report which SQL dialect to use when building queries.


Step 2: Add the Database Implementation File to Your Project

Dotnet Report separates database logic into individual C# files.
You only need to pull one file per database type into your project.

All implementations are available in the Dotnet Report GitHub repository:

https://github.com/dotnetreport/dotnetreport/tree/net6/feature/mysql-and-informix/Models

MySQL

File: MySqlDatabaseConnection.cs

curl -o MySqlDatabaseConnection.cs https://raw.githubusercontent.com/dotnetreport/dotnetreport/refs/heads/net6/feature/mysql-and-informix/Models/MySqlDatabaseConnection.cs

PostgreSQL

File: PostgresDatabaseConnection.cs

curl -o PostgresDatabaseConnection.cs https://raw.githubusercontent.com/dotnetreport/dotnetreport/refs/heads/net6/feature/mysql-and-informix/Models/PostgresDatabaseConnection.cs

Oracle

File: OracleDatabaseConnection.cs

curl -o OracleDatabaseConnection.cs https://raw.githubusercontent.com/dotnetreport/dotnetreport/refs/heads/net6/feature/mysql-and-informix/Models/OracleDatabaseConnection.cs

OleDb / DB2

File: OleDbDatabaseConnection.cs

curl -o OleDbDatabaseConnection.cs https://raw.githubusercontent.com/dotnetreport/dotnetreport/refs/heads/net6/feature/mysql-and-informix/Models/OleDbDatabaseConnection.cs

📌 Note: You only need the file for the database types you plan to use.


Step 3: Install the Required NuGet Package

Each database requires its own ADO.NET provider.
Add the appropriate NuGet package(s) to your project.

Oracle

dotnet add package Oracle.ManagedDataAccess.Core --version 23.26.0

PostgreSQL

dotnet add package Npgsql --version 9.0.4

MySQL

dotnet add package MySql.Data --version 9.5.0

OleDb / Informix / DB2

dotnet add package System.Data.OleDb --version 9.0.10
dotnet add package Net.IBM.Data.Db2 --version 8.0.0.500

Step 4: Update the Database Type in GetSettings

In your backend API project, open DotnetReportApiController and locate the GetSettings() method.

Update the dbtype value to match your selected database.

Example (Oracle)

private DotNetReportSettings GetSettings()
{
    DotNetReportHelper.dbtype = DbTypes.Oracle.ToDbString();
    ...
}

Other Options

DbTypes.PostgreSQL.ToDbString();
DbTypes.MySql.ToDbString();
DbTypes.OleDb.ToDbString();

This setting ensures Dotnet Report routes all query generation to the correct database implementation.


Once these steps are complete:

  • Dotnet Report will generate SQL compatible with your database
  • Joins, filters, grouping, and aggregations will follow the correct syntax
  • You can mix database types across different workspaces if needed

No additional configuration is required.


Notes & Best Practices

  • Restart the application after changing database providers
  • Ensure the database user has permission to read metadata (tables, views, schemas)
  • For Oracle, confirm the correct schema is set or accessible
  • For MySQL and Postgres, verify case-sensitive identifiers if applicable

How can we help?