# Downloading ADO.NET providers from NuGet

A number of ADO.Net providers are supplied for download from NuGet. Typically these NuGet packages are added to a Visual Studio project and the required DLLs are downloaded as part of building the project. Downloading all the DLLs manually can be tricky so here is a guide.

First install the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>). This gives you the `dotnet` command line tool. You can then use the following PowerShell commands to download the ADO.Net provider and required DLLs for Designer.

## PostGres provider (npgsql)

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
# Create a new C# project called PostGresProvider
dotnet new console -n PostGresProvider --use-program-main --langVersion 7.3

# Navigate into the project directory
Push-Location PostGresProvider

# Change the project target to .NET framework 4.8
(Get-Content -path PostGresProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path PostGresProvider.csproj

# Add Npgsql NuGet package (version 8 is the most recent version that supports .NET framework)
dotnet add package npgsql --version 8.0.8

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\postgresprovider.*

# Return to previous directory
Pop-Location
```

Files will be in `.\postgresprovider\bin\release\net48\`.

## Snowflake provider (Snowflake.Data)

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
# Create a new C# project called SnowflakeProvider
dotnet new console -n SnowflakeProvider --use-program-main --langVersion 7.3

# Store current directory
Push-Location SnowflakeProvider

# Change the project target to .Net Framework 4.8
(Get-Content -path SnowflakeProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path SnowflakeProvider.csproj

# Add Npgsql Nuget package to the project
dotnet add package Snowflake.Data

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\snowflakeprovider.*

# Back to where we were
Pop-Location
```

Files will be in `.\snowflakeprovider\bin\release\net48\`.

## MySQL provider (MySql.data)

This is the Oracle-supplied provider.

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
# Create a new C# project called MySqlProvider
dotnet new console -n MySqlProvider --use-program-main --langVersion 7.3

# Store current directory
Push-Location MySqlProvider

# Change the project target to .Net Framework 4.8
(Get-Content -path MySqlProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path MySqlProvider.csproj

# Add Npgsql Nuget package to the project
dotnet add package MySql.Data

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\mysqlprovider.*

# Back to where we were
Pop-Location
```

Files will be in `.\mysqlprovider\bin\release\net48\`.

## MySQL provider (MySqlConnector)

This is the open source provider that connects to both MySQL and MariaDB: [https://github.com/mysql-net/MySqlConnector](<https://github.com/mysql-net/MySqlConnector>)

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
# Create a new C# project called MySqlConnectorProvider
dotnet new console -n MySqlConnectorProvider --use-program-main --langVersion 7.3

# Store current directory
Push-Location MySqlConnectorProvider

# Change the project target to .Net Framework 4.8
(Get-Content -path MySqlConnectorProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path MySqlConnectorProvider.csproj

# Add Npgsql Nuget package to the project
dotnet add package MySqlConnector

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\mysqlconnectorprovider.*

# Back to where we were
Pop-Location
```

Files will be in `.\mysqlconnectorprovider\bin\release\net48\`.

## DuckDB provider

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
mkdir DuckDBProvider

# Create a new C# project called DuckDBProvider
dotnet new console -n DuckDBProvider --use-program-main --langVersion 7.3

# Store current directory
Push-Location DuckDBProvider

# Change the project target to .Net Framework 4.8
(Get-Content -path DuckDBProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path DuckDBProvider.csproj

# Add Npgsql Nuget package to the project
dotnet add package DuckDB.NET.Data.Full

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\duckdbprovider.*

# Back to where we were
Pop-Location
```

Files will be in `.\duckdbprovider\bin\release\net48\`.

## Oracle ODP.NET (managed) provider

Requires the [.NET SDK](<https://dotnet.microsoft.com/en-us/download>).

PowerShell

```powershell
# Create a new C# project called ODPNetProvider
dotnet new console -n ODPNetProvider --use-program-main --langVersion 7.3

# Store current directory
Push-Location ODPNetProvider

# Change the project target to .Net Framework 4.8
(Get-Content -path ODPNetProvider.csproj -Raw) -replace '.*?','net48' | Set-Content -Path ODPNetProvider.csproj

# Add Npgsql Nuget package to the project
dotnet add package Oracle.ManagedDataAccess

# Build the project
dotnet build --configuration Release

# Remove unnecessary files
Remove-Item bin\release\net48\odpnetprovider.*

# Back to where we were
Pop-Location
```

Files will be in `.\odpnetprovider\bin\release\net48\`.

## Troubleshooting

If you get the message "error: There are no versions available for the package..." when running the scripts, you may need to add the default NuGet package source by running:

PowerShell

```powershell
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
```
