Skip to content

PostgreSQL

Simon Hughes edited this page Jun 5, 2021 · 24 revisions

GAC Installation

The PostgreSQL npgsql.dll file needs to be installed into the GAC.

Visit https://github.com/npgsql/npgsql/releases and download the latest MSI installer by looking into the assets of a release. The latest one with an MSI installer is currently v4.1.8

In both c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config and c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config approximately line 168 I have the following system.data xml where you will see the Npgsql Data Provider has been added

<system.data>
    <DbProviderFactories>
        <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        <add name="Npgsql Data Provider" invariant="Npgsql" description=".NET Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=4.1.3.0, Culture=neutral, PublicKeyToken=5D8B90D52F46FDA7"/>
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.22.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
</system.data>

To install npgsql into the global assembly cache (GAC) I ran the following command:

cd C:\Users\[user]\.nuget\packages\npgsql\4.1.3.1\lib\net461
gacutil.exe /i Npgsql.dll

Notice I am using the .NET 4.6.1 version because the generator runs as a T4 template using .NET, and not a .NET Core template.

Looking at which version I have installed with gacutil /l npgsql shows the following:

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  npgsql, Version=4.1.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL

Number of items = 1

Which means I have v4.1.3 installed, so I am a little out of date, but it works fine for reverse generation.

Further reading here.

Clone this wiki locally