Repository navigation
Description
Changes from 3.0.x
- NpgsqlDdexProvider 3.1.0 doesn't contain
Npgsql.dllanymore.- It doesn't depend on specific version of Npgsql.dll.
- Menu commands are removed:
- [Setup Npgsql DbProviderFactories...]
- [Uninst Npgsql DbProviderFactories...]
- [Check Npgsql project installation...]
Tested cases
Case 1:
- VisualStudio 2015 Pro Update 3
- NpgsqlDdexProvider 3.1.0
- NuGet EntityFramework6.Npgsql 3.1.1
- NuGet Npgsql 3.1.8
How to setup
GAC Installer
Obtain GAC installer (e.g. Npgsql-3.1.8.msi) from https://github.com/npgsql/npgsql/releases
And install it.
Note: Uninstall other versions of Npgsql GAC installer. It prevents new setup.
Note: Uninstall command line:
msiexec.exe /x {772a9e26-9ab8-4011-bce6-d95b19d22b57}
DDEX package
Obtain NpgsqlDdexProvider-3.1.0.vsix from https://github.com/npgsql/npgsql/releases/tag/v3.1.8
And install it.
Note: Uninstall command line. new version overwrites older installation, so uninstall is not mandatory.
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\VSIXInstaller.exe" /u:958b9481-2712-4670-9a62-8fe65e5beea7
Obtain latest Npgsql.dll
Create a new project, and then get Npgsql.dll via NuGet targeting .NETFramework,Version=4.5 or such.
Copy Npgsql.dll to PrivateAssemblies
NpgsqlDdexProvider 3.1.0 doesn't contain Npgsql.dll for a trick. Copy it to:
VS2012 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies
VS2013 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies
VS2015 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies
- NpgsqlDdexProvider ≦ 3.0.x used assembly redirection technique using AppDomain.AssemblyLoad Event.
- It cannot be used in 3.1.0.
- So please write
<bindingRedirect>in your own way...
Add bindingRedirect to devenv.exe.config
Edit devenv.exe.config and add these lines to line before </assemblyBinding>:
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.8.0" newVersion="3.1.8.0" />
<codeBase version="3.1.8.0" href="PrivateAssemblies\Npgsql.dll"/>
</dependentAssembly>VS2012 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config
VS2013 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.config
VS2015 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.config
Note: Replace 3.1.8.0 with your Npgsql.dll assembly version.
Remove Npgsql ADO.NET Data Provider from devenv.exe.config
GAC installer installs ADO.NET Data Provider to both:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config(32-bit)C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config(64-bit)
So, remove Npgsql provider declaration from <DbProviderFactories> of devenv.exe.config, where NpgsqlDdexProvider 3.0.x setup modified.
Here is the initial status of <DbProviderFactories>
<system.data>
<DbProviderFactories>
<remove invariant="Microsoft.SqlServerCe.Client" />
<remove invariant="Microsoft.SqlServerCe.Client.3.5" />
<remove invariant="Microsoft.SqlServerCe.Client.4.0" />
<add name="Microsoft SQL Server Compact 4.0 Client Data Provider" invariant="Microsoft.SqlServerCe.Client.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact 4.0 Client" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>The setup process has done!
New project setup
- [File][New][Project…]
- [Templates][Visual C#][Windows][Console Application]
- ConsoleApplication2 or such
- [Tools][NuGet Package Manager][Package Manager Console]
- Run
Install-Package Npgsql
NuGet output:
Attempting to gather dependencies information for package 'Npgsql.3.1.8' with respect to project 'ConsoleApplication2', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'Npgsql.3.1.8' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Npgsql.3.1.8'
Resolved actions to install package 'Npgsql.3.1.8'
Adding package 'Npgsql.3.1.8' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'Npgsql.3.1.8' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'Npgsql.3.1.8' to 'packages.config'
Successfully installed 'Npgsql 3.1.8' to ConsoleApplication2
- Run
Install-Package EntityFramework6.Npgsql
NuGet output:
Attempting to gather dependencies information for package 'EntityFramework6.Npgsql.3.1.1' with respect to project 'ConsoleApplication2', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'EntityFramework6.Npgsql.3.1.1' with DependencyBehavior 'Lowest'
Resolving actions to install package 'EntityFramework6.Npgsql.3.1.1'
Resolved actions to install package 'EntityFramework6.Npgsql.3.1.1'
Adding package 'EntityFramework.6.0.0' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'EntityFramework.6.0.0' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'EntityFramework.6.0.0' to 'packages.config'
Executing script file 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages\EntityFramework.6.0.0\tools\init.ps1'
Executing script file 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages\EntityFramework.6.0.0\tools\install.ps1'
Type 'get-help EntityFramework' to see all available Entity Framework commands.
Successfully installed 'EntityFramework 6.0.0' to ConsoleApplication2
Adding package 'EntityFramework6.Npgsql.3.1.1' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'EntityFramework6.Npgsql.3.1.1' to folder 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages'
Added package 'EntityFramework6.Npgsql.3.1.1' to 'packages.config'
Executing script file 'c:\users\user\documents\visual studio 2015\Projects\ConsoleApplication2\packages\EntityFramework6.Npgsql.3.1.1\tools\install.ps1'
Successfully installed 'EntityFramework6.Npgsql 3.1.1' to ConsoleApplication2
- Build once
- [Project][Add New Item…]
- [Visual C# Items][Data][ADO.NET Entity Data Model]
- [EF Designer from database] and [Next >] at Choose Model Contents
- Prepare a connection and [Next >] at Choose Your Data Connection
- Turn on check tables and [Finish] at Choose Your Database Objects and Settings
keyvaluestore table:
-- Table: public.keyvaluestore
-- DROP TABLE public.keyvaluestore;
CREATE TABLE public.keyvaluestore
(
key text NOT NULL,
value text,
CONSTRAINT keyvaluestore_pkey PRIMARY KEY (key)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.keyvaluestore
OWNER TO npgsql_tests;- You may need to click [OK] at Security Warning.
- The model is built.
- Write sample code and run.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
using (npgsql_testsEntities db = new npgsql_testsEntities()) {
// Add a new entity
db.keyvaluestore.Add(new keyvaluestore {
key = DateTime.Now.ToString(),
value = "Hello!"
});
db.SaveChanges();
// Display all entities
foreach (var keyvalue in db.keyvaluestore) {
Console.WriteLine("{0}={1}", keyvalue.key, keyvalue.value);
}
}
}
}
}- Run several times, it will remember previously added entities.









Activity
macro2002 commentedon Nov 7, 2016
Completely made from this statement, but the formation of a Contents Model after selecting the database, nothing happens. Already read all the posts with a similar problem, but never found a solution. VS 2015.
The connection of the worker, was checked by aspx.
phillashworth commentedon Dec 15, 2016

After setting up my connection when I right-click on a table in the Visual Studio Server Explorer and select "Retrieve data" it fails if the table is mixed case e.g. for table `AspNetRoles` it fails with attached screenshot; it appears to be querying the table name in lower case.rcote commentedon Jan 13, 2017
Hello.
I get the exact same issue as @phillashworth. Any solution yet on that issue?
Also, think I get the same issue as @macro2002. I try to follow your example and create a connection to my db using [project][add new item...] but get nothing after I setup the connection string parameters in the wizard. It just stops and get me nothing even though the connection to the db was tested and it worked.
Could the two issues be related?
roji commentedon Jan 20, 2017
@phillashworth and @rcote, could you please open a separate issue for the mixed-case problem you're seeing? The original problem will probably disappear with the upcoming, rewritten version of the extension - see #1407. This version will soon be released with Npgsql 3.2, I might also do a prerelease before then. If it persists after upgrading to the new extension, please post back.
roji commentedon Jan 21, 2017
@phillashworth and @rcote I can confirm there's an issue with non-lowercase identifiers, opened #1408 to track.
dropyghost commentedon Jan 26, 2017
I have an error running the Entity Data Model
I install
My devenv.exe
My Machine.config
kenjiuno commentedon Jan 27, 2017
@dropyghost
It seems
type="Npgsql.NpgsqlFactory, Npgsql, Version=3.0.7.0, ..."is still written in somewhere.Please check,
<DbProviderFactories>indevenv.exe.config,and
<DbProviderFactories>inApp.config.roji commentedon Jan 27, 2017
Note: you probably want to try the new, just-released VSIX extension. However, as @kenjiuno suggests you need to clean up any settings in your system (
machines.config,App.config,devenv.exe.config, GAC installation...).dropyghost commentedon Jan 27, 2017
Ok I remove the line from devenv.exe.config.
One question maybe for other with the same problem: Just changing the file doesnt reflect the change. What you have to do to that reflect? I just close everything and open VS again,
Now I got another issue, Test Connection say succeded, but OK show this error:
Btw I saw now the connection string is just a line. I must say I never remember the string connection format so was easier for me with the multi properties window as was before. So if you could keep both versions would be great.
dropyghost commentedon Jan 27, 2017
@roji the link doesnt work.
I can try cleaning the GAC, but Im not familiar with that area, I can do all kind of query and program in C# but even when you guys do a great work, installing and make it running every new version is very troublesome for me. So I just try dont upgrade very often.
roji commentedon Jan 27, 2017
@dropyghost just checked and the link does work (I may have posted it too quickly after uploading the extension). Try again now.
The main effort into the new VSIX is precisely to make the installation/uninstallation as painless as possible - on a clean setup you only need to install the VSIX and it'll work out of the box, without any sort of machine-wide changes (GAC, machines.config).
Unfortunately if you already installed before you'll need to clean up. Here are a few suggestions:
gacutil /u npgsqlC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.configandC:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config(the precise version number may be different). Remove any assembly bindings or db provider factory registrations for Npgsqldevenv.exe.configorApp.config, removing anything Npgsql-related from it.After this cleanup, attempt to install the 3.2.0 VSIX and hopefully all will be well...
dropyghost commentedon Jan 27, 2017
@roji
Nope, same message. Not found. Maybe isnt public yet?
Btw, If help, I can use the namespace, create connection and use commands, the problem is just with the EF data model.
And maybe I cant help writing code, but if you need anyone to test release I'm willing to help.
1 remaining item
roji commentedon Jan 27, 2017
Ah, one second - the extension may be set to private - looking into it.
roji commentedon Jan 27, 2017
OK, my bad - there's a process with Microsoft to make things public.
For now, I've uploaded the VSIX to the github releases page - you can download from there.
roji commentedon Jan 30, 2017
OK, the VSIX is (finally!) publicly available at the link already posted. I can also confirm that searching for npgsql within the Visual Studio "Extensions and Updates" dialog shows the extension.
dropyghost commentedon Feb 1, 2017
@roji Where is the install instructions for 3.2 vsix?
I install
Then I install npgsql 3.2 from nugget, but that didnt install Entity Framework as dependecy.
So I install 6.1.3 but then Npgsql.EntityFramework cant be installed.
dropyghost commentedon Feb 1, 2017
Ok, need to use the package Manager console instead of nuget manager.
But then when try to enter any data the windows close on any keypress.
roji commentedon Feb 2, 2017
@dropyghost, here's the documentation page for the VSIX. As it says, you should not be installing Npgsql into your GAC, so there's no need to install the MSI. It's recommended you remove it, the VSIX is all you need.
The VSIX is enough to use some PostgreSQL database features in VS, but (as the docs say) if you want Entity Framework functionality you need to install EF6 inside your own project, via Nuget (no GAC, no VSIX). Entity Framework isn't a dependency of Npgsql (it's the other way around) - many people use Npgsql without EF.
As you've already found out, Npgsql.EntityFramework is the old package name for pre-3.0, the current EF6 nuget is EntityFramework6.Npgsql, installable via nuget (either via the VS UI or the package manager console).
Regarding your error (the Window closing after any keystroke), can you try again after uninstalling the Npgsql MSI?
tkprof commentedon Feb 6, 2017
@roji uninstall everything / remove every entries, then install the 3.2.0 vsix works for me. Thank you!
roji commentedon Feb 6, 2017
Great!
waleedkhan91 commentedon May 23, 2017
Awesome. This is exactly what i was looking for. Thumbs up!!!
pedro-lb commentedon Dec 15, 2017
@kenjiuno, I've added a new guide on how to do the initial setup on Visual Studio 2015/2017.
Link: #1752
alibekp commentedon Aug 8, 2018
Hello! I have a little problem. I've added a new
Model.edmx, it shows me my data from Postgres correctly, but when i open aDesigner.csit's empty... Here a code inside myDesigner.cs:When i'm trying to Generate Database from Model it's sayshows next error:

Here's my Web.config
alibekp commentedon Aug 8, 2018
alibekp commentedon Aug 8, 2018
austindrenski commentedon Aug 8, 2018
@alibekp This issue is pretty old. Could you please open a new issue with a concise description of the problem you're encountering and some minimal version information?
alibekp commentedon Aug 8, 2018
Please come to my new issue
https://github.com/alibekp/site/issues/1