Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Visual Studio Design Time Support DDEX Provider

Emill edited this page · 6 revisions

VS2013Pro+NpgsqlDdexProvider+EF6 how to

(by @kenjiuno) Reference:


Install assemblies into GAC

  1. Grab the latest setup program (.exe-file) from and run it.
  2. Select all components to install.

Prepare new project for testing

  1. Launch Visual Studio 2013.
  2. [FILE]→[New]→[Project...]
  3. [Console Application]
  4. Name is [testef] for example.

Install EntityFramework 6, Npgsql and Npgsql.EntityFramework from NuGet

  1. Right click project [testef]
  2. [Managet NuGet Packages...]
  3. Type "EntityFramework" at [Search Online (Ctrl+E)]
  4. Install "EntityFramework". Version is 6.1.1 for now.
  5. Do the same for Npgsql and Npgsql.EntityFramework.

Add EF6 provider into App.config

  1. Open [App.config]
  2. Add provider-element into providers-element.
<?xml version="1.0" encoding="utf-8"?>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />

If you want to be able to run your code on machines that have not installed Npgsql with the installer (or manually added Npgsql and Npgsql.EntityFramework to the GAC and added a Npgsql DbProviderFactory to machine.config) you also need the following:

    <remove invariant="Npgsql"/>
    <add name="Npgsql Data Provider" 
         description=".Net Data Provider for PostgreSQL" 
         type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" 
         support="FF" />

Build once

  1. Build your project.

New ADO.NET Entity Data Model

  1. Right click project [testef]
  2. [Add]→[New Item...]
  3. [ADO.NET Entity Data Model]
  4. Name is [Model1] for example.
  5. Click [Add]
  6. [EF Designer from database] at Choose Model Contents. ef1
  7. [New Connection] at Choose Your Data Connection. ef2
  8. [PostgreSQL Database] at Change Data Source. ef3
  9. Fill properties in Connection Properties. It is easy to fill everything by setting [ConnectionString]. ef4

My sample ConnectionString:


Note: Don't forget to set PreloadReader to true.

  1. Select [Yes, include the sensitive data in the connection string.] in this case for easy setup. ef5

  2. Select tables which you want, at Choose Your Database Objects and Settings. ef6

Note: remember the text npgsql_tests_efModel at [Model Namespace].

  1. Click OK for Security Warning. T4 Templates generator warns you as it contains just runnable C# code. ef7

  2. You will get a generated model. ef8

Edit your program.cs

Just my sample code for npgsql_tests_ef database.

About the name of "npgsql_tests_efEntities" class, check your [Model Namespace] entered above. Replace "Model" with "Entities", like it is "npgsql_tests_efModel".

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace testef
    class Program
        static void Main(string[] args)
            using (npgsql_tests_efEntities Context = new npgsql_tests_efEntities())
                foreach (Blogs blog in Context.Blogs)
                    Console.WriteLine(blog.BlogId + " " + blog.Name);

Sample output: ef10

NpgsqlDdexProvider build tips

(by @kenjiuno) Reference:

VS2010 users

You'll need VS2010 Professional or greater.

SP0 users:

SP1 users:

If you need newer NpgsqlDdexProvider2010.pkgdef, create your own manually. pkgdef is a kind of registry file for our DDEX registration. Note: It is needed only if you change contents of NpgsqlDataProviderRegistration class.

Command example:

H:\Dev\Npgsql\NpgsqlDdexProvider>"H:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Tools\Bin\CreatePkgDef.exe" /out=NpgsqlDdexProvider2010.pkgdef /codebase bin\Release-net40\NpgsqlDdexProvider.dll


Visual Studio (R) PkgDef Creation Utility.
Copyright (c) Microsoft Corporation. All rights reserved.

CreatePkgDef : warning : The Assembly specified at 'bin\Release-net40\NpgsqlDdexProvider.dll' cannot be loaded because an alternate copy with the same identity
exists in the Assembly probing path at 'H:\Dev\Npgsql\NpgsqlDdexProvider\bin\Release-net40\NpgsqlDdexProvider.dll'. The Assembly at 'H:\Dev\Npgsql\NpgsqlDdexPro
vider\bin\Release-net40\NpgsqlDdexProvider.dll' will be loaded instead.
Assembly: NpgsqlDdexProvider
Output file: NpgsqlDdexProvider2010.pkgdef

インストールされている製品:   NpgsqlDdexProviderPackage、Version 1.0
パッケージ:          NpgsqlDdexProviderPackage {958b9481-2712-4670-9a62-8fe65e5beea7}
サービス:          PostgreSQL Provider Object Factory

SUCCEEDED:        NpgsqlDdexProvider

Check: How to create a pkgdef file for your Visual Studio Package

VS2012 users

You'll need VS2012 Professional or greater.

VS2013 users

You'll need VS2013 Professional or greater.

How to check if Npgsql DDEX was correctly loaded.

(by @kenjiuno) Reference:

Here are tips to check.

  • Check your connection dialog: addconn

  • Make sure to edit both x86 and x64's machine.config. VS2013 runs 64bit mode on x64 machine. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config

      <add name="Npgsql Data Provider" 
           description=".Net Data Provider for PostgreSQL" 
           type="Npgsql.NpgsqlFactory, Npgsql, Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" 
           support="FF" />

Note that the Version attribute above should match the version of the Npgsql Assembly you are using.

How to debug Npgsql DDEX extension

In order to debug it, you will need to use the Experimental Instance of Visual Studio.

  • In the NpgsqlDdex project, right click and select properties.
  • Go to Debug tab
  • Click on the radio button for Start External Program. Point it to the devenv.exe binary. On my machine it's located at

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe

Then set the command line arguments to /rootsuffix Exp

Save everything and now, just right click the NpgsqlDdex project -> Debug -> Run in a new instance. A new Visual Studio instance should be run where the extension will be made available and you can debug it in the first visual studio instance.


Something went wrong with that request. Please try again.