Skip to main content

Npgsql Design time support preview available for download!

UPDATE2: For some reason, Blogger lost the original post. I had to republish it.


UPDATE: Jerónimo told me that you must use the Npgsql version which is inside the zip file in order to make it work.

After so much time (more than I wanted it to take) Npgsql finally has a initial design time support for Visual Studio!

This work was done by Jerónimo Milea. Jerónimo let me know he was working on DDEX support on this thread after I said I was working on DDEX support for Npgsql.

He sent me his working copy and I started to play with it. Note that as a preview version many things may not work ok and we wanted you to provide us feedback so we can fix any bugs.

You can download the project file from our downloads page.

Design time support is provided as a zip file containing support code as well as a copy of Npgsql project file. So, everything you need to start working with design time support is already packaged for you.

When you unzip the file, you will have three folders and a project file. Open up this project file in Visual Studio 2010.

There are three projects. The Npgsql.Provider project is there for historical reasons, Jerónimo told me. We will clean it up in another release. The main project is the Npgsql.Provider2. Set it up as your startup project. Right Click -> Set up as Startup Project.



After that, tell Visual Studio to build all projects. After everything is compiled ok, there are still some other steps to be done:


  1. Install Npgsql.dll and Mono.Security.dll to GAC. 
  2. Add Npgsql as a provider factory in machine.config

Install Npgsql.dll and Mono.Security.dll to GAC
    
    Go to the Npgsql2\bin\debug4\ folder and add Npgsql.dll and Mono.Security.dll to GAC:
    
    gacutil -i Npgsql.dll
    gacutil -i Mono.Security.dll
  


    Note that you will need to start a Visual Studio Command Prompt so command line tools are available to you. This shortcut is inside Visual Studio 2010 programs folder in the Visual Studio Tools subfolder.

Add Npgsql as a provider factory in machine.config

    In the machine.config file, located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config you have to add following line: 



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

    This line goes inside the DbProviderFactories section.


Playing with Design Time support project


    After config Npgsql in gac and machine.config, it's time to run the project.

    As this project will work inside VS.Net, you will need to debug VS.Net itself in order to have the project running inside it. In order to do that, you have to specify VS.net as the debug target. To do that, open Npgsql.Designer2 project properties and in the Debug tab, check the value of "Start external program" edit text. It is set to the path of devenv.exe. Note that it is the path of (x86) Program Files folder. This is ok if you are using a 64-bits windows installation. If you are using a 32-bits install (as I do), you just have to remove the (x86) from the path and you are set.



    After setting everything up, you can hit F5 to start the project ( you specified Npgsql.Designer2 as your startup project, right?). A new VS.Net will show up and your first VS.Net will be attached to it in debug mode. Now, comes a very important step you have to make: Inside Npgsql.Designer2 folder, there is a file called NpgsqlProvider.gen.reg. You have to merge this file to your registry every time you start VS.Net to debug the project. This is needed because VS.Net as it is started by the project, has a command line option which makes it use an alternate registry tree which is cleaned up every time this VS.net is started. This reg file has the settings to register Npgsql.Designer inside VS.Net.

    That's it! If everything is ok, you may now create a new project or open an existing one and add a new datasource to it using Postgresql as the backend! This procedure is somewhat complex, but after it is done once, you only have to repeat the merge registry file part.

    Please, let me know if you have any problems setting this up. Also, please, send your comments and bug reports to our bug tracker: bugs.npgsql.org



    Again, thanks Jerónimo for all his help and for this excellent work.

Comments

OMG said…
I did what is mentioned above, now, what should i do next to get a c# program to talk to the database?
S1l4s said…
Excelente!!! Npsql já era bom, agora ficara melhor ainda. Como anda estes testes, ja tem alguma versao estavel dessa versao para design time.
Sloven said…
It is only 3 folders in downloaded package and no any project file in top level. I've manualy tryed to build all projects in all folders. Then I've loaded to GAC Npgsql.dll, Mono.Security.dll. After this I've added key to machine config "DbProviderFactories" section. But I steel don't see Npgsql provider even in .NET namespaces.
Then I've tryed to use edmgen.exe to generate DB model. but error apears:
error 7001: The specified store provider 'Npgsql' cannot be found in the configuration, or 'Npgsql' is not valid.
Unable to find the requested .Net Framework Data Provider. It may not be installed.

Plese help. I would like to use Npgsql2 with Entity Framework
Idalvo Gabriel said…
It has the project file in the zip file
Filosofo said…
Hi

You said this "
When you unzip the file, you will have three folders and a project file. Open up this project file in Visual Studio 2010."

But when i unzip the file there is only 3 folders.....and no project file :(

Where is this project???
Cesar said…
How to install it to run it regularly on the standard hive of VS? So far I understand that this runs on VS' Experimental Hive, but I'd like to run it on the regular one to not having to always debug the project with another instance of VS.

Also, I have a second question: Why the designer shows a warning regarding unsupported "money" type?
Anonymous said…
is it working for VS2011 ?
why dont you put it on github, much better for collab... ?
Enoch99 said…
Hello Francisco Figueiredo,
two things: first thing I couldn't find the project file, and after I created my own solution, I was not able to find the folder Npgsql.Designer2 and the file NpgsqlProvider.gen.reg. Could you check the zip file once again and make sure?

Secondly, I'd like to know what differences it has compared to Devart's driver?

Thanks.
Enoch99 said…
Hello Francisco Figueiredo,
two thing: first one is some files seems to be missing in the download. I couldn't find the project file, and could not find the folder Npgsql.Designer2 and file NpgsqlProvider.gen.reg after I build the project from my own solution.

Secondly, what differences does Npgsql have compared to Devart's driver?

Regards.
Hi, Enoch99. I just checked the zip file and it is ok. What file are you donwloading? You should download the file Npgsql.Provider.zip http://pgfoundry.org/frs/download.php/3067/Npgsql.Provider.zip

About Devart's driver, I don't know very much about the differences as I didn't try it. I think one big missing feature of Npgsql today is vs.net design time support. I hope to get that fixed. Sorry for not having too much information about the differences.
Hi, Nicolas. It is not working with vs.net 2011 :(

Today we have a mirror in github. Check out: git.npgsql.org

I hope it helps.
Hi, Cesar. We are working to provide a non Experimental Hive version so it will be easier to use. Sorry for that.
Hi, Filosofo.

Sorry for that. You should open the project inside Npgsql.Designer2 folder.
We are working to get those bugs fixed in a new version of Npgsql with design time support.

Sorry for all those problems.

The project which must be built is inside the Npgsql.Designer2 folder.

I hope to get more news soon.
jeanfs said…
Francisco,

i opened the solution Npgsql.Provider2 that´s inside the folder Npgsql.Provider2, and when I tried to build it didn´t built and showed me 98 erros, so I cant go on the process. What should I do? What´s is wrong?
Gianpy said…
Hi Francisco,
I've downloaded your files but when I try to open solution files (VS2008 or VS2010) I found a different Project tree and of course it doesn't work. Do you have idea of a working release date ?
Thank you
Gianpy
Gianpy said…
Hi Francisco, I've tried to download zip file and work with it but I've a different project tree in solution (both 2008 and 2010).
Do you have idea of a Visual Studio working release date ?
Thank you
Gianpy
Anonymous said…
There's no any solution or project file in root directory. There's only one .sln file at all - in Npgsql-2.0.11 directory, but when I tryed to open it in VS 2010, it couldn't load other projects. What should I do in order to get desired result?

Why can't you just post prebuilded assemblies?
JC said…
Oi Francisco! Tudo bom?

I was just wondering whether you have any update on the new NpgSql version, the one with the DDEX support...

Thanks in advance for letting us know!

Cheers,
Gianluca
Unknown said…
sorry Francisco, thank you a lot for your work, but this isn't neither an hive version...

Npgsql.Designer2 folder isn't there in any .zip downloaded, any other project rebuild generate a lot of error and missing dependencies.

We will wait for better release,thanks
Vidas said…
Hi, Sloven
I've problem exactly the same as you, because, maybe, of use VS 2010 express?
Vidas said…
Hi, Sloven
I've problem exactly the same as you, because, maybe, of use VS 2010 express?
How to install Npgsql design time support for VS 2008, same way?
Mamoud said…
Hi Francisco,
I just download the ZIP file of the project, but no "NpgsqlProvider.gen.reg" file in this. and no folder "Npgsql.Designer2" too?
Thank you.
Anonymous said…
Do we need to do the same thing if we are using Npgsql.dll and Mono.Security.dll from Npgsql2.0.11.94-bin-ms.net4.0 build?
Linquize said…
Where is the .reg file to register in registry? I could not find it in current source code!
Yusuf said…
Hello, how can I use for vs2012, it works only in VS2010. Thank you for your interest.
Semen said…
Hi Francisco,
Is there any known issue about this message?
"Could not get column information to database object...."
Fired when try to drag&drop table from server explorer into the dataset. VS2010Pro
Everything works fine, except d&d action.
Anonymous said…
Excellent! Does it work with Visual C# Express?
Unknown said…
Excellent! Does it work with Visual C# Express?
ጦማር said…
Thanks for the support , i followed the steps and everything works fine but what i am looking for is if there is a way to permanently merge the registry file and work like other data providers without running the project and merging the registry each and every time.
Unknown said…
Will this work in VS2012? I am hesitant to try it if it might screw something up on a non-compatible version. I am trying to get Entity Framework on VS2012/Postgres working so I can so a Dynamic Data web site.
kamil said…
Hello
I have an application in VS2010 which uses npgsql.
If I switch on my application from VS or manually from debug (where I have mono and npgsql) it works.
But if I move my .exe to another place e.g. d:/ or pendrive or another computer my application turns on but if try connect to data base application disapear.
How to link .dll files with .exe?
Hi, Kamill.

You should put Npgsql.dll and Mono.Security.dll in the same folder of your .exe.

I hope it helps.
Unknown said…
This comment has been removed by the author.
Unknown said…
Hi Francisco

I've downloaded the .zip file and when I open the project file "Npgsql.Provider2.csproj" in VS 2010 shows "Npgsql.Provider2(não disponivel)".

Could you please help me?

Thanks
Unknown said…
Hi,

I'm trying to run this application with VS 2012 and was able to set it up by following the steps here. I got the new VS 2012 instance running but when I try to add a new ADO.NET Entity Model, I do not get to choose Npgsql for my new connection. Can you please help?

Thanks,
Abhi.
Unknown said…
As a follow-up, I went into the registry file and replaced \VisualStudio\10.0Exp_Config to \VisualStudio\11.0Exp_Config.
Unknown said…
Hi,
Thanks for the support!
I followed the steps and everything works fine but when I closed and reopen project, I can't connect to database any more.
Unknown said…
I was retried, It can connect and read data from database, but can not update data model with error message: "An exception of type 'Microsoft.VSDesigner.Data.Local.ConnectionStringConverterServiceException' occurred while attempting to update from the database. The exception message is: ''.".
How can I fix this error?

Thanks!
Unknown said…
I would like to thank you for the efforts you have made in writing this article.
Signature:
download free descargar whatsapp plus and download baixar whatsapp plus online and descargar whatsapp , baixar whatsapp gratis
conan said…
Le Pelagos du chef Gillespie semble être le modèle "à deux lignes" qui arborait le mouvement calibre ETA 2824-2 (les nouveaux modèles arborent désormais des mouvements COSC de calibre Tudor MT5612).copie montre Vous pouvez consulter Ben Clymer de HODINKEE en passant en revue cette montre très ici. Lancée en 2012, la Pelagos est la première montre de plongée moderne de Tudor, avec des spécifications adaptées à toutes les aventures.fausse montre Il est livré avec une résistance à l'eau de 500 m et le système de réglage du fermoir à ressort sans effort. Venant en titane, avec la lunette en céramique mate entièrement éclairée, la Pelagos est une montre à outils pour montre-outil.replique rolex Il n'est pas étonnant que le chef Kevin ait choisi celui-ci.

Popular posts from this blog

UUID datatype and COPY IN/OUT support added to cvs

Hi all! It was just added support to uuid datatype in cvs head. This type will be available in next Postgresql release 8.3. Thanks to David Bachmann for his patch! You can get more info about this patch in this mailing list post . Also was added support for copy in and copy out operations. Now, users can provide streams which can be copied directly to and from Postgresql tables! Thanks to Kalle Hallivuori for providing a patch! Thanks to Truviso for giving support to Kalle. More info about that including a demo and ready to use compiled Npgsql.dll versions can be found here . That's it! As soon as we get more features added, I will post info about them here. Stay tuned! :)

Npgsql Tips: Using " in (...)" queries with parameters list and "any" operator

Hi, all! We have received some users questions about how to send a list of values to be used in queries using the "in" operator. Something like: select foo, bar from table where foo in (blah1, blah2, blah3); Npgsql supports array-like parameter values and the first idea to have this working would try to use it directly: NpgsqlCommand command = new NpgsqlCommand("select * from tablee where field_serial in (:parameterlist)", conn); ArrayList l = new ArrayList(); l.Add(5); l.Add(6); command.Parameters.Add(new NpgsqlParameter("parameterlist", NpgsqlDbType.Array | NpgsqlDbType.Integer)); command.Parameters[0].Value = l.ToArray(); NpgsqlDataReader dr = command.ExecuteReader(); but unfortunately this won't work as expected. Npgsql will send a query like this: select * from tablee where field_serial in ((array[5,6])::int4[]) And Postgresql will complain with the followin...

Using Entity Framework 6 with Npgsql 2.1.0

UPDATE (2014-05-19): Marek Beneš noticed a problem in the default connection factory config. It is fixed now. Thanks, Marek! UPDATE (2014-02-20): I created a new post explaining how to get Npgsql 2.1.0. Although this post is about EF 6, I'd like to talk about our current situation to support both EF 6 and EF4.x which explain why there are some subtle changes between EF 4.x and EF 6.x App.config settings.  Support for EF versions 4.x and 6.x Sometime after we started to work on Npgsql 2.1.0, we started to add code to support EF6 and decided to reorganize our Entity Framework support code. Shay created a pull request to organize this change and isolate the EF code out of core Npgsql code. The result was the creation of two separated assemblies: Npgsql.EntityFramework.dll for EF6 and above; Npgsql.EntityFrameworkLegacy.dll for EF4.x. Only when using Npgsql with EF6 you will need to reference Npgsql.EntityFramework.dll assembly. This is needed because the EF ...