Native ADO.Net data providers

List the native ADO.Net providers and how to load them

An ADO.Net data provider connects to a data source such as SQL Server, MySQL, PostgreSQL but also ODBC and OLE DB data source, and provides a way to execute queries against that data source in a consistent manner that is independent of the data source and data source-specific functionality.

DubUrl doesn't remove the need to add a reference to the package containing the ADO.Net provider, neither the need to register the factory of the ADO.Net provider. Click here for more info

To embrace the world of DubUrl, you need to follow some conventions regarding the way you’re providing your connection URL. The table bellow is listing the different aliases than can be provided in the scheme but also the name of the ADO.Net data provider package and the name that you should use as the provider invariant name.

List of Native ADO.Net data providers

Database Aliases Package name / Provider invariant name        
Microsoft SQL Server mssql, ms, sqlserver, mssqlserver Microsoft.Data.SqlClient Go to Nuget repository      
MySQL mysql, my MySqlConnector Go to Nuget repository      
PostgreSQL pg, pgx, pgsql, postgres, postgresql Npgsql Go to Nuget repository      
Oracle Database oracle, or, ora Oracle.ManagedDataAccess Go to Nuget repository      
IBM DB2 db2 IBM.Data.Db2 Go to Nuget repository      
MariaDB maria, mariadb MySqlConnector Go to Nuget repository      
DuckDB duck, duckdb DuckDB.NET.Data Go to Nuget repository      
Firebird SQL fb, firebird FirebirdSql.Data.FirebirdClient Go to Nuget repository      
SQLite3 sq, sqlite Microsoft.Data.Sqlite Go to Nuget repository      
Teradata td, teradata, tera Teradata.Client Go to Nuget repository      
Snowflake sf, snowflake Snowflake.Data Go to Nuget repository      
CockRoachDB cr, cockroach, cockroachdb, crdb, cdb Npgsql Go to Nuget repository      
CrateDB crt, crate, cratedb Npgsql Go to Nuget repository      
SingleStore sg, sgs, singlestore, single SingleStoreConnector Go to Nuget repository      
Trino tr, trino NReco.PrestoAdo Go to Nuget repository      
QuestDb quest, questdb Npgsql Go to Nuget repository      
Timescale ts, timescale Npgsql Go to Nuget repository      

Additional packages

SQLite3 is expecting additional libraries (.dll) to work properly. If these libraries are missing, you ‘ll receive an exception You need to call SQLitePCL.raw.SetProvider(). To avoid this exception, you must include the package SQLitePCLRaw_bundle_e_sqlite3 into your solution or copy the following dlls:

  • SQLitePCLRaw.batteries_v2.dll
  • SQLitePCLRaw.core.dll
  • SQLitePCLRaw.provider.e_sqlite3.dll

Example

Following example shows how to use DubUrl to connect to a PostgreSQL database.

Referencing the package of the ADO.Net data provider, using the package name described in the 3rd column of the table

dotnet add package Npgsql

Registering the factory of the ADO.Net data provider

DbProviderFactories.RegisterFactory("Npgsql", Npgsql.NpgsqlFactory.Instance);

Open a connection to the database named dbname and hosted on a server named serverName. Note that the scheme of the URL is set to pgsql to specify that the database is a PostgreSQL (other options than pgsql such as pg or postgres could have been used).

var conn = new ConnectionUrl("pgsql://{serverName}/{dbName}").Open();

ODBC driver locators