Installing and Configuring the .NET Connector v4.0.10.2
This chapter describes how to install and configure the EDB .NET Connector.
Installing the .NET Connector
You can use the EDB .NET Connector Installer (available from the EDB website) to add the .NET Connector to your system. After downloading the installer, right-click on the installer icon, and select Run As Administrator
from the context menu. When prompted, select an installation language and click OK
to continue to the Setup
window.
The .NET Connector Installation wizard
Click Next
to continue.
The Installation dialog
Use the Installation Directory
dialog to specify the directory in which the connector will be installed, and click Next
to continue.
The Ready to Install dialog
Click Next
on the Ready to Install
dialog to start the installation; popup dialogs confirm the progress of the installation wizard.
The installation is complete
When the wizard informs you that it has completed the setup, click the Finish
button to exit the dialog.
You can also use StackBuilder Plus to add or update the connector on an existing Advanced Server installation; to open StackBuilder Plus, select StackBuilder Plus
from the Windows Apps
menu.
Starting StackBuilder Plus
When StackBuilder Plus opens, follow the onscreen instructions.
Select the EnterpriseDB.Net Connector
option from the Database Drivers
node of the tree control.
Selecting the Connectors installer
Follow the directions of the onscreen wizard to add or update an installation of an EDB Connector.
Configuring the .NET Connector
Please see the following environment-specific sections for information about configuring the .NET Connector:
- Referencing the Library Files. General configuration information applicable to all components.
- .NET Framework 4.0 Instructions for configuring for use with .NET Framework 4.0.
- .NET Framework 4.5 Instructions for configuring for use with .NET Framework 4.5.
- .NET Framework 4.5.1 Instructions for configuring for use with .NET Framework 4.5.1.
- .NET Standard 2.0. Instructions for configuring for use with .NET Standard 2.0.
- Entity Framework 5/6. Instructions for configuring for use with Entity Framework.
- EDB VSIX. Instructions for configuring for use with EDB VSIX.
Please see the following environment-specific sections for information about configuring the .NET Connector: • Referencing the Library Files. General configuration information applicable to all com- ponents. • .NET Framework 4.0. Instructions for configuring for use with .NET Framework 4.0. • .NET Framework 4.5. Instructions for configuring for use with .NET Framework 4.5. • .NET Framework 4.5.1. Instructions for configuring for use with .NET Framework 4.5.1. • .NET Standard 2.0. Instructions for configuring for use with .NET Standard 2.0. • Entity Framework 5/6. Instructions for configuring for use with Entity Framework. • EnterpriseDB VSIX. Instructions for configuring for use with EnterpriseDB VSIX.
Referencing the Library Files
To reference library files with Microsoft Visual Studio:
- Select the project in the
Solution Explorer
. - Select
Add Reference
from theProject
menu. - When the
Add Reference
dialog box opens, browse to select the appropriate library files.
Optionally, the library files can be copied 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 within the namespace. The namespace is:
EnterpriseDB.EDBClient
If you are using Entity Framework 6, the following additional namespace is required:
EntityFramework6.EntepriseDB.EDBClient
The method you use to include the namespace varies by the type of application you are 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, write:
using EnterpriseDB.EDBClient;
.NET Framework Setup
The following sections describe the setup for various .NET versions.
.NET Framework 4.0
If you are using .NET Framework version 4.0, the data provider installation path is:
C:\Program Files\edb\dotnet\net40\
The following shared library files are required:
EDBDataProvider.2.0.2.dll
Mono.Security.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 Framework 4.5
If you are using .NET Framework version 4.5, the data provider installation path is:
C:\Program Files\edb\dotnet\net45\
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
System.Memory.dll
You must also add the following dependencies to your project:
System.Threading.Tasks.Extensions.dll
System.Runtime.CompilerServices.Unsafe.dll
System.ValueTuple.dll
System.Memory.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 Framework 4.5.1
If you are using .NET Framework version 4.5.1, the data provider installation path is:
C:\Program Files\edb\dotnet\net451\
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
System.Memory.dll
You must also add the following dependencies to your project:
System.Threading.Tasks.Extensions.dll
System.Runtime.CompilerServices.Unsafe.dll
System.ValueTuple.dll
System.Memory.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 Standard 2.0
For .NET Standard Framework 2.0, the data provider installation path is:
C:\Program Files\edb\dotnet\netstandard2.0\
The following shared library files are required:
EnterpriseDB.EDBClient.dll
System.Threading.Tasks.Extensions.dll
System.Runtime.CompilerServices.Unsafe.dll
System.ValueTuple.dll
You must also add the following dependencies to your project:
System.Runtime.CompilerServices.Unsafe.dll
System.ValueTuple.dll
Note
If your target framework is .Net Core 2.0, then include the following file in your project:
System.Threading.Tasks.Extensions.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.
Entity Framework 5/6
To set up .NET Connector for usage with Entity Framework, the data provider installation path is:
C:\Program Files\edb\dotnet\EF\
The following shared library files are required:
EntityFramework5.EnterpriseDB.EDBClient.dll
EntityFramework6.EnterpriseDB.EDBClient.dll
To configure the .NET Connector for use with Entity Framework, the data provider installation path is:
Note
Entity Framework can be used with the EnterpriseDB.EDBClient.dll
library available in the net45
and net451
subdirectories.
See Referencing the Library Files for information about referencing library files.
Add the <DbProviderFactories>
entries for the ADO.NET
driver for Postgres to the app.config
file. Add the following entries:
In the project’s app.config
file add the following entry for provider services under the EntityFramework/providers tag:
The following is an example of the app.config
file:
Note
The same entries for <providers>
and <DbProviderFactories>
are valid for the web.config
file and the app.config
file.
Depending upon the type of application you are using, you may be required to import the namespace into the source code (see Referencing the Library Files).
For usage information about Entity Framework, refer to the Microsoft documentation.
EDB VSIX for Visual Studio 2015/2017/2019
The EDB Data Designer Extensibility Provider (EDB VSIX) is a component that integrates Advanced Server database access into Visual Studio, thus providing Visual Studio integrated features.
EDB VSIX allows you to connect to Advanced Server from within Visual Studio's Server Explorer and create a model from an existing database. Therefore, if Visual Studio features are desired, then EDB VSIX must be utilized.
EDB VSIX files are located in the following directory:
C:\Program Files\edb\dotnet\vsix
The files available at the above location are:
EnterpriseDB.vsix
SSDLToPgSQL.tt
Installation and Configuration for Visual Studio 2015/2017/2019
Use the following steps to install and configure EDB VSIX.
Step 1: Install EDB VSIX to the desired version of Visual Studio with the EnterpriseDB.vsix
installer.
If you already have an earlier version of the VSIX installed, we highly recommended that you uninstall it to avoid conflicts.
It is no longer necessary or recommended to have EnterpriseDB.EDBClient
in your global assembly cache (GAC).
Step 2: Relaunch Visual Studio and verify from the Tools > Extensions and Updates…
menu that the EDB extension is installed.
Step 3: Use the gacutil utility at the Visual Studio Developers Command Line from the fol- lowing location to add the System.ValueTuple.dll library to the global assembly cache (GAC):
C:\Program Files\edb\dotnet\vsix\System.ValueTuple.dll
For example:
gacutil.exe /i System.ValueTuple.dll
Step 4: From the Server Explorer, right-click on Data Connections
, click Add Connection
, and verify that the Enterprisedb Postgres Database
data source is available.
Model First and Database First Usage
Step 1: Use the gacutil utility at the Visual Studio Developers Command Line to add the EntityFramework5.EnterpriseDB.EDBClient.dll library to the global assembly cache (GAC):
For example:
gacutil.exe /i EntityFramework5.EnterpriseDB.EDBClient.dll
Step 2: Add the <DbProviderFactories>
entries for the ADO.NET driver to the machine.config
file. Include the following entries:
For the attribute-value pairs, the double-quoted strings should not contain excess white space characters, but be configured on a single line. The examples shown in this section may be split on multiple lines for clarity, but should actually be configured within a single line such as the following:
description=".NET Data Provider for EnterpriseDB PostgreSQL"
For 64-bit Windows, the machine.config
file is in the following location:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
For 32-bit Windows, the machine.config
file is in the following location:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
Step 3: Place the DDL generation template SSDLToPgSQL.tt
in the Visual Studio EntityFramework Tools\DBGen\
folder as shown in the following example:
Note
Select this template SSDLToPgSQL.tt
in your EDMX file properties.
Step 4: Add the EnterpriseDB.EDBClient.dll
and EntityFramework6.EnterpriseDB.EDBClient.dll
files to project references. see Referencing the Library Files for information about referencing library files.
Step 5: In the project’s app.config
file, add the following entry for provider services under the EntityFramework/providers tag:
The following is an example of the app.config
file.