Support for PostgreSQL Database (Npgsql .NET Provider)

Topics: Development Team Discussion
Oct 16, 2007 at 9:53 AM
I have Data Access Application Block extension for PostgreSQL database (Npgsql .NET provider)

Did you add my implementation to entlibcontrib project or i must create separate project?
Oct 19, 2007 at 9:00 PM
cool! join the gang.

I added you as a developer, looking forward to your contributions!
Nov 8, 2007 at 2:59 PM
Hi !
Is it working? I am very interested in the Postgresql support by the DAAB.
Thank you for your work !
Nov 9, 2007 at 6:34 AM

amine_tn wrote:
Hi !
Is it working? I am very interested in the Postgresql support by the DAAB.
Thank you for your work !

Hi! Yes, is working with Npgsql2.0beta1 (
I send send patch to entlibcontrib project, also my code available in npgsql CVS, and you can see him here:
Nov 13, 2007 at 8:49 AM
thank you !
can you explain how can I integrate it in the entlib?
Nov 13, 2007 at 9:15 AM
I said nothing. I compiled it. thanks :)
Nov 13, 2007 at 10:33 AM

amine_tn wrote:
I said nothing. I compiled it. thanks :)

good luck! :)
Nov 16, 2007 at 4:41 AM
Oleg thanks for the work.

I was able to integrate it with EntLib 3.1. and Npgsql Beta2

In order to make it work
1. I had to install Npgsql provider to GAC (not sure if it was necessary)
2. In machine.config added Npgsql .NET Provider like this (add name="PostgreSQLClient Data Provider" invariant="Npgsql" description="Beta2 .Net Framework Data Provider for PostgreSQL" type="Npgsql, Npgsql, Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" )
3. Recompiled EntLib 3.1 with code that Oleg created.
4. Configured connection string in web.config of my test web application using EntLib config tool. You will have to change EnterpriseLibraryConfigurationSet from "Microsoft Signed" to "EntLib3Src" if you use integrated in Visual Studio EntLib configuration tool. This setting can be found if you click on solution name in your project and view properties. (Thnaks to Tom Hollander)
5. Configured custom provider using EntLib 3.1 configuration tool. Now my web.config setting for EntLib look like this

(section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=null" /)
(dataConfiguration defaultDatabase="Connection String")
(add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.PostgreSql.PostgreSqlDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=null" name="Npgsql" /)
(add name="Connection String" connectionString="Server=;Port=5432;User Id=USERNAMEGOESHERE;Password=USERPASSWORDHERE;Database=MyDBName;" poviderName="Npgsql" /)

6. Created "User" table in new db on PostgreSql server.

And this is all was done that later I was able to do this:

Dim db As Database = DatabaseFactory.CreateDatabase
Me.GridView1.DataSource = db.ExecuteDataSet(CommandType.Text, "select * from ""Users""")

The best thing about it I can now substitute any database engine on background without changing any application code as long as I stay with the more or less standard ANSI SQL features and data types that many RDBMS will support.

I hope I saved someone couple hours of sleep with my ramblings. I had real fun putting it all together.

Now just left to hookup NHibernate to Npqsl and see how that will work.

I heard a lot of good things about PostgreSql and finally got around to try it.
Nov 16, 2007 at 6:33 AM
Thanks Vlad! Greate guidance!

1. I had to install Npgsql provider to GAC (not sure if it was necessary)

Not necessary.