Installing and configuring the .NET Connector v8.0.5.1

Installing the .NET Connector

You can install the EDB .NET Connector using either the EDB installer or the installer from NuGet.org.

Installing and configuring the .NET Connector from NuGet.org

Install NuGet package via command line

Launch a terminal from your solution folder and run:

dotnet add package EnterpriseDB.EDBClient

This command downloads and installs the EDB .NET Connector matching your .NET version. Your project is then ready to import the EDB .NET Connector namespace:

using EnterpriseDB.EDBClient;

You can find all the EDB .NET Connector satellite packages at NuGet.org.

For more information, see the EDB .NET Connector Now Published on NuGet blog post.

Install NuGet package via Visual Studio interface

  1. Right-click your project or solution and select Manage NuGet package.
  2. Search the package using enterprisedb.edbclient as the search text.
  3. Select the EnterpriseDB.EDBClient package.
  4. Select Install to proceed to package download and installation.

This command downloads and installs the EDB .NET Connector matching your .NET version. Your project is then ready to import the EDB .NET Connector namespace:

using EnterpriseDB.EDBClient;

For more information, see the EDB .NET Connector Now Published on NuGet blog post.

Installing the .NET Connector using EDB installer

You can use the EDB .NET Connector installer to add the .NET Connector to your system. The installer is available from the EDB website.

  1. After downloading the installer, right-click the installer icon, and select Run As Administrator. When prompted, select an installation language and select OK to continue to the Setup window.

    The .NET Connector Installation wizard

  2. Select Next.

    The Installation dialog box

  3. Use the Installation Directory dialog box to specify the directory in which to install the connector. Select Next.

    The Ready to Install dialog box

  4. To start the installation, on the Ready to Install dialog box, select Next. Popups confirm the progress of the installation wizard.

    The installation is complete

  5. When the wizard informs you that it has completed the setup, select Finish.

You can also use StackBuilder Plus to add or update the connector on an existing EDB Postgres Advanced Server installation.

  1. To open StackBuilder Plus, from the Windows Apps menu, select StackBuilder Plus.

    Starting StackBuilder Plus

  2. When StackBuilder Plus opens, follow the onscreen instructions.

  3. From the Database Drivers node of the tree control, select the EnterpriseDB.Net Connector option.

    Selecting the Connectors installer

  4. Follow the directions of the onscreen wizard to add or update an installation of an EDB Connector.

Configuring the .NET Connector

For information about configuring the .NET Connector in each environment, see:

Referencing the library files

To reference library files with Microsoft Visual Studio:

  1. In the Solution Explorer, select the project.
  2. Select Project > Add Reference.
  3. In the Add Reference dialog box, browse to select the appropriate library files.

Optionally, you can copy the library files to the specified location.

Before you can use an EDB .NET class, you must import the namespace into your program. Importing a namespace makes the compiler aware of the classes available in the namespace. The namespace is EnterpriseDB.EDBClient.

The method you use to include the namespace varies by the type of application you're writing. For example, the following command imports a namespace into an ASP.NET page:

 <% import namespace="EnterpriseDB.EDBClient" %>

To import a namespace into a C# application, use:

 using EnterpriseDB.EDBClient;

.NET framework setup

Each .NET version has specific setup instructions.

.NET 8.0

For .NET 8.0, the data provider installation path is:

C:\Program Files\edb\dotnet\net8.0\

You must add the following dependencies to your project:

EnterpriseDB.EDBClient.dll

Depending upon the type of application you use, you may be required to import the namespace into the source code. See Referencing the library files for this and other information about referencing library files.

.NET 7.0

For .NET 7.0, the data provider installation path is C:\Program Files\edb\dotnet\net7.0\.

You must add the following dependencies to your project:

  • EnterpriseDB.EDBClient.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET 6.0

For .NET 6.0, the data provider installation path is:

C:\Program Files\edb\dotnet\net6.0\

You must add the following dependencies to your project:

  • EnterpriseDB.EDBClient.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing library files.

.NET Framework 4.7.2

For .NET Framework 4.7.2, the data provider installation path is:

C:\Program Files\edb\dotnet\net472\.

You must add the following dependency to your project. You may also need to add other dependencies from the same directory:

  • EnterpriseDB.EDBClient.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET Framework 4.8

For .NET Framework 4.8, the data provider installation path is:

C:\Program Files\edb\dotnet\net48\.

You must add the following dependency to your project. You may also need to add other dependencies from the same directory:

  • EnterpriseDB.EDBClient.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET Framework 4.8.1

For .NET Framework 4.8.1, the data provider installation path is:

C:\Program Files\edb\dotnet\net481\.

You must add the following dependency to your project. You may also need to add other dependencies from the same directory:

  • EnterpriseDB.EDBClient.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET Standard 2.0

For .NET Standard Framework 2.0, the data provider installation path is:

C:\Program Files\edb\dotnet\netstandard2.0\.

You must add the following dependencies to your project:

  • EnterpriseDB.EDBClient.dll

  • System.Threading.Tasks.Extensions.dll

  • System.Runtime.CompilerServices.Unsafe.dll

  • System.ValueTuple.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET Standard 2.1

For .NET Standard Framework 2.1, the data provider installation path is C:\Program Files\edb\dotnet\netstandard2.1\.

The following shared library files are required:

  • EnterpriseDB.EDBClient.dll

  • System.Memory.dll

  • System.Runtime.CompilerServices.Unsafe.dll

  • System.Text.Json.dll

  • System.Threading.Tasks.Extensions.dll

  • System.ValueTuple.dll

Depending on your application type, you might need to import the namespace into the source code. See Referencing the library files for this and the other information about referencing the library files.

.NET Entity Framework Core

To configure the .NET Connector for use with Entity Framework Core, the data provider installation path is:

C:\Program Files\edb\dotnet\EF.Core\EFCore.PG\net8.0 The following shared library file is required:

  • EnterpriseDB.EDBClient.EntityFrameworkCore.PostgreSQL.dll

See Referencing the library files for information about referencing the library files.

The following NuGet packages are required:

  • Microsoft.EntityFrameworkCore.Design

  • Microsoft.EntityFrameworkCore.Relational

  • Microsoft.EntityFrameworkCore.Abstractions

For usage information about Entity Framework Core, see the Microsoft documentation.

Prerequisite

To open a command prompt:

Select Tools > Command Line > Developer Command Prompt.

Install dotnet-ef (using the command prompt),

dotnet tool install --global dotnet-ef

Sample project

Create a new Console Application based on .NET 8.0.

Add Reference to the following EDB assemblies:

  • EnterpriseDB.EDBClient.EntityFrameworkCore.PostgreSQL.dll

  • EnterpriseDB.EDBClient.dll

Add the following NuGet packages:

  • Microsoft.EntityFrameworkCore.Design

  • Microsoft.EntityFrameworkCore.Relational

  • Microsoft.EntityFrameworkCore.Abstractions

Database-first scenario

Issue the following command to create model classes corresponding to all objects in the specified database:

dotnet ef dbcontext scaffold Host=<HOST>;Database=<DATABASE>;Username=<USER>;Password=<PASSWORD>;Port=<PORT> EnterpriseDB.EDBClient.EntityFrameworkCore.PostgreSQL -o Models

Code-first scenario

Add code for defining a DbContext and create, read, update, and delete operations.

For more details, see the Microsoft documentation.

Issue the following commands to create the initial database and tables:

  dotnet ef migrations add InitialCreate --context BloggingContext

  dotnet ef database update --context BloggingContext