Skip to main content

Npgsql 2.2.0 final release is out!

This is Npgsql 2.2.0 Final Release

This release contains 249 commits since the last stable release. Includes bug fixes, improvements and new features.

Update notice: If you have been using Npgsql 2.2.0-rc2, you don't need to update to this version. They are the same except for the Assembly version information.

Major highlights

Visual Studio DDEX support


Kenji Uno added support for DDEX. Now you can use Npgsql with Visual Studio data designer. This is a missing feature a lot of our users requested in the past. Kenji added a tutorial about how to use Npgsql with DDEX. You can find it here:


Entity Framework


David Karlaš added support for EFMigration and Database creation in EF6+.
Now it is possible to start Code First projects without needing to create a database upfront. EntityFramework and Npgsql will take care of it.

Emil Lenngren added support for a lot of missing features of EntityFramework.

A list containing fixes from David and Emil as well as others for EntityFramework can be seen here:


SSLStream support


In this release, SSLStream is on by default.
If you want to use Mono.Security, you will need to use the following line in your code:
NpgsqlConnection.UseSslStream = false; 
Note that in future releases, this option may not be available anymore as we are removing the dependency on Mono.Security assembly. Let us know in the forums if you have any problem with ssl when using SSLStream. This will help us check if we will be able to remove Mono.Security assembly.


Added support for JSON, JSONB and HSTORE datatypes

Shay added support for those datatypes.


Added GSSAPI support on Windows

Brian Crowell added support for GSSAPI on windows. Now it is easier to use Active Directory when authenticating users.


Removed support for protocol v2

Postgresql versions which use only protocol 2 are very old and don't receive support from postgresql group anymore. By removing support for protocol version 2, we removed a lot of code and can focus on functionalities provided by protocol 3.


Removed support for Postgresql 8.4 and below

In this thread, we talked about making Npgsql support the officially supported postgresql versions. we talked about making Npgsql support the officially supported postgresql versions. Postgresql has a table of officially supported versions and we decided to follow this table to guide us which postgresql version we will have support to.
This doesn't necessarily mean that Npgsql won't work on unsupported versions. It may work if we don't add any SQL or unsupported feature. For example, today Npgsql 2.2 works only on Postgresql 8.2 and above because we added server side support for command timeout handling and some other queries which aren't supported on earlier versions.
If you are using earlier postgresql versions, please, use an older version of Npgsql. We are creating a compatibility table to show which Postgresql version Npgsql works with.


Fixed bugs:

[#91] Support for EFMigration and Database creation
[#152] NpgsqlInterval different constructors different ToString
[#158] NpgsqlCommand.Dispose() should execute "DEALLOCATE " for a prepared command
[#177] XML data type doesn't seem to be quoting parameters properly on insert
[#179] NpgsqlCommandBuilder automatic sql commands configuration
[#188] Buffer too small problem in NpgsqlCopySerializer
[#201] Dynamic type parameters: Cannot cast System.Int32 into any valid DbType after upgrading from to
[#208] ObjectDisposeException
[#217] Impossible to insert a Double.NaN value
[#219] [#1011005] using 2 NpgsqlCopyIn at the same time
[#223] HasRows property's bug
[#231] NpgsqlParameterCollection.Clear() doesn't reset NpgsqlParameter.Collection
[#225] Handle IEnumerable parameter
[#233] Cannot insert to tables which have only one column
[#246] Take followed by Skip is generated incorrectly in Entity Framework
[#262] FirstOrDefault() on navigation property subquery throws “Not Implemented” Exception
[#264] Mono.Security is outdated
[#269] Fix 's' value mapped to the 'a' byte
[#280] Bad SQL produced when selecting a field that was also used in the orderBy of a let subquery
[#287] Fix operator handling and date functions for EF
[#296] parameter parsing fails (regression) and duplicate [#240] NpgSqlCommand does not substitute parameters when there is a string with escaped apostrophe
[#315] Fix query parameter processing to more correctly match PostgreSQL's lexer
A list of the issues and pull requests merged for this release can be found at github here:


Known Issues

There are some issues we are working for the next maintenance release 2.2.1. You can check which issues we are working on here:



I'd like to give a special thanks to Kenji Uno for his excellent work with Npgsql DDEX support. DDEX support was one of the biggest missing features of Npgsql.
I'd like to thank Emil Lenngren for all his work with Entity Framework improvements and insightful comments, David Karlaš for his help with Entity Framework support. Shay Rojansky, Glen Parker and Josh Cooley for all contributions and comments, and a big thanks to all the other contributors who helped us to make this release.



Downloads are available on Nuget, github and pgfoundry.
Please, give it a try and let us know what you think. Drop by our user forums to discuss or send your bug reports to our issues section on github.


 List of contributors for this release

Kenji Uno
Shay Rojansky
Glen Parker
Emil Lenngren
David Karlaš
Brian Crowell
Tuan Nguyen
Frans Bouma
Jaspalsinh Chauhan
Josh Cooley
Martin Willey
Francisco Figueiredo Jr.
Javier Torres
Kevin Pullin
Michael de Lang
Oskar Gewalli
Sunny Ahuwanya
Thomas Radioyes


tryhp3 said…
Is support for ASP.NET Identity?
SHIMA91 said…
This comment has been removed by the author.
SHIMA91 said…
How use Code First with mvc 4

Install EntityFramewor 6.1.1, Npgsql, Npgsql EntityFramewor.

I created simple Single Page Application but the database is not created.

Web.config the same

What am I doing wrong
Unknown said…
This comment has been removed by the author.
Unknown said…
This comment has been removed by the author.
Unknown said…

When you use postgres with no access to postgres db (my host dont give me access) the entityframewok cannot apply updates (code first) to db beacause required permissions do postres DB. Debuging Npgsql I found the problem at NpgsqlServices at UsingPostgresDBConnection Method.

This occurs because postegres can connect first in postresDB, after in my DB, but this behavior was wrong.

I rebuild your dlls without Database change and works, but not create database, but its fine to me.

My email is

Thanks, regards.
Jools said…
Same as Daniel, the
really bugs me when access rights are denied to postgres database

Unfortunately this is 100% sure in my scenarios!
Unknown said…

I have the solution if you want.
Contact by email.

Unknown said…
This comment has been removed by the author.
Unknown said…

you have done a great job with Npgsql and we are using it for 3 years.

But now we are getting

ERROR: 08P01: invalid message format

with character containing \0.

I'am using parameters for execution of sql statement.

Npgsql Version with Postgres 9.4.1 x64

Can you help us?
Unknown said…
Posts shared useful information and meaningful life, I'm glad to be reading this article and hope to soon learn the next article. thank you
i like play games friv 4 online and play games 2 girls 2 Download facebook movel
Unknown said…
great article, I was very impressed about it, wish you would have stayed next share
facebook iniciar sesion gratis - Sitio Oficial iniciado sesión en Facebook lengua española. facebook inicio sesion entrar rápido, facebook iniciar sesion en tu cuenta de entrar facebook
Unknown said…
I wish you much fun with my comments, perhaps this blog will be a great blog someday I hope, I really liked this part of the article, with a big and interesting topic has helped a lot of people who don't oppose things that people should know, thanks a lot.
happy wheels
super mario bros
Anonymous said…
Mario | Mario Games: best Super Mario games and top Super Mario Bros games for you. Go now
conan said…
Le chef Gillespie n'est pas seulement un chef renommé, mais aussi, vous l'aurez deviné, un veilleur.replique montre La montre qu'il est repéré portant sur le spectacle n'est rien de moins qu'un Tudor Pelagos. Mais le plaisir ne s'arrête pas là. Il a associé sa montre à un bracelet NATO de style Bond.

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

Stream seek error

Hi all! Since Npgsql RC1, we started to receive some error reports about problems when closing connections. The typical stack trace looked like this: System.NotSupportedException : This stream does not support seek operations. at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin) at System.IO.BufferedStream.FlushRead() at System.IO.BufferedStream.WriteByte(Byte value) − at Npgsql.NpgsqlQuery.WriteToStream(Stream outputStream) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlQuery.cs:line 62 − at Npgsql.NpgsqlReadyState.QueryEnum(NpgsqlConnector context, NpgsqlCommand command) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlReadyState.cs:line 64 − at Npgsql.NpgsqlConnector.ReleasePlansPortals() in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnector.cs:line 373 − at Npgsql.NpgsqlConnectorPool.UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnectorPool.cs:line 541 − at Npgsql.NpgsqlConnectorPool.ReleasePooledConnector(NpgsqlConn