Repository navigation
Description
Introduction
So, I've had a hard time setting up the NpgsqlDdexProvider with Visual Studio 2017, because the DDEX package mentioned in the previous tutorial isn't compatible anymore. So I've decided to write a quick guide on how to set it up for VS 2015/2017.
Also, this guide should work on previous versions.
Old tutorial link: #1299
Npgsql and the extensions mentioned here are in no way developed by me.
Credits goes to all those who developed it.
Cleaning for our Setup
If you have any previous version of Npgsql installed and setup within your VS, you'll need to clean your setup. Mostly you'll need to remove the Npgsql ADO.NET Data Provider from devenv.exe.config.
- devenv.exe.config is located within the Common7 folder of your VS installation. This folder should be located at Program Files/Microsoft Visual Studio/[2017, 2015, etc]/[Professional, Enterprise, etc]/Common7.
In that file, the DbProviderFactories section under system.data should be as following:
<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>
Installation
Npgsql
First you'll need to install Npgsql. Download the latest release from the link below and install it.
- DO NOT Install the GAC extension! Only the Npgsql itself.
- https://github.com/npgsql/npgsql/releases
Ddex Package
Now you'll need to install the Ddex package to connect your VS 2015/2017 with PostgreSQL. You can obtain the latest version on the link below.
Copy Npgsql.dll to PrivateAssemblies
As in the old tutorial, i've done this step and it worked normally. I honestly don't know if it is necessary (maybe not), I guess @kenjiuno can help us on this matter.
From the original tutorial:
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 in your own way...
After the Installation
Now that we're all set up, restart your machine for the changes to take effect. Open your VS and build your solution, then you should be able to manage your database within Entity Framework.
New Project Setup
To test our setup, we can use the topic New Project Setup from the old tutorial. It should work the same way, but without the warnings.
Link: #1299
If you still have any problems, please let me know and we'll figure out on this thread.
Activity
dropyghost commentedon Mar 12, 2018
I think you miss install EntityFramework6.Npgsql from nuget.
roji commentedon Mar 13, 2018
I have no idea what this means... There are two things - an MSI (which is the GAC installer) and a VSIX (which is the Visual Studio extension). This is quite confusing.
On a more general note, I've seen that quite a few people have had issues getting the VSIX to work - I haven't been able to reproduce those issues on my machine. The last time I checked, simply installing the VSIX worked out of the box.without any need to install Npgsql into the GAC (via the MSI) or any tinkering (e.g. copying anything to PrivateAssemblies).
At least in theory, there's absolutely no reason to need anything beyond the VSIX. The extension is completely self-contained, coming with Npgsql.dll and making all the necessary changes. What I have seen is people upgrading from old versions of the VSIX, or whose system has already been tweaked somehow (Npgsql in the GAC, in the global machines.config), and this interference causes issues. I have yet to see a clean system where the VSIX doesn't work out of the box.
But that doesn't mean there aren't issues. I don't have much time to spend on the VSIX - there's too much Npgsql stuff that's more important. In addition, the VSIX is less important than it used to be - EF Core no longer has any VS integration, making the VSIX interesting only for EF6 users, and even there it's somewhat optional (unless I'm mistaken Powershell commands can be used to do the same operations).
In short, if somebody wants to step up and really dig into the issues around the VSIX that would be very welcome. I'm not talking about another tutorial explaining how to install VSIX, but rather to really try to understand where the issues are coming from, and fix them. I'd gladly accept pull requests both for the VSIX and its documentation if they make sense and are backed by evidence that they're necessary.
Am closing this as there's nothing actionable but we can continue the conversation.