Tuesday, December 10, 2013

Npgsql 2.0.14 released!

Update (2013-12-22): was released with a fix for entity framework boolean value handling. See this issue and this commit for more info about this fix.
Package zip files are already available from pgfoundry and github.

* * *

After a lot of time since last stable release, Npgsql 2.0.14 is out! This is a small bugfix release with fix for hangs which could happen when connecting to Postgresql 9.3. 

This bug appeared when Postgresql sent an error message. Npgsql had a problem handling some error code fields and then hang while processing it. Whooops! :) 
Thanks to Glen Parker, it is fixed on github.  If you are having hang problems while using Npgsql after upgrade the server to 9.3 version, this version is for you.


Those who are paying attention to the version number may have noticed that the version number is 2.0.14 and not 2.0.13 as it should be. After all, we already had a 2.0.13-beta1 released

The fact is that after 2.0.13-beta1, we had a lot of changes. From performance tweaks to better Entity Framework support and many other changes that we decided to skip 2.0.13 and call it Npgsql 2.1! Yes, you read it right. After so many years in the 2.0.x versions, we will ship our first 2.1 version. I'll post more info about it in a future post. I hope this version number change doesn't give too much confusion.

You can grab Npgsql 2.0.14 from nuget repository. You can install it directly from Visual Studio and Xamarin Studio through Nuget Package Manager.

We are also packing zip distributions to put on our downloads section. We are having some problems with our downloads host but as soon as we get them available I'll update this post. They are already available at pgfoundry and github.

As always, send your comments and feedback about this release. They are very welcome and will help us to get more goodies in your hands on next releases.


Mark Gomes said...

i'm get this error:

The 'Instance' member of the Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql, Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

this means that this version does not support version 6.x of the Entity Framework?

Piotr Trychta said...

What version of the Entity Framework is supported?

brm said...

I have the same error, is not supported?
any solution?

Francisco Figueiredo Jr. said...

Npgsql 2.0.14 doesn't have support for EF6. It has support for EF 4.3.1. More information about how to use it you can find here: http://fxjr.blogspot.com.br/2013/06/npgsql-code-first-entity-framework-431.html.

EF6 support will be in the upcoming 2.1 version. You can grab a current snapshot from github which has support for EF6 from here: https://github.com/npgsql/Npgsql/archive/master.zip

You will need to compile it on visual studio and grab the resulting assemblies from the Npgsql.EntityFramework/bin folder.

I hope it helps.

Please, let me know if you have any problem.

徐硕 said...
This comment has been removed by the author.
Scott Xu said...

Would it be possible to upload a 2.1 Alpha version in nuget with EF6 support?

Piotr Trychta said...

I use PostgreSQL 9.3

Combination Npgsql and EF 4.3.1, works well for me.

Combination Npgsql and EF 4.3.1 throw error:

An unhandled exception of type 'System.Data.ProviderIncompatibleException' occurred in EntityFramework.dll

Additional information: The provider did not return a ProviderManifest instance.

Message: Value cannot be null.
Parameter name: input

at System.Xml.XmlReaderSettings.CreateReader(Stream input, Uri baseUri, String baseUriString, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri)
at System.Xml.XmlReader.Create(Stream input)
at Npgsql.NpgsqlProviderManifest.CreateXmlReaderForResource(String resourceName) in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlProviderManifest.cs:line 265
at Npgsql.NpgsqlProviderManifest..ctor(String serverVersion) in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlProviderManifest.cs:line 14
at Npgsql.NpgsqlServices.GetDbProviderManifest(String versionHint) in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlServices.cs:line 107
at System.Data.Common.DbProviderServices.GetProviderManifest(String manifestToken)

TargetSite:{System.Data.Common.DbProviderManifest GetProviderManifest(System.String)}

What is wrong?

Francisco Figueiredo Jr. said...

Hi Scott Xu!

We are working to release a beta of 2.1 soon! You can give it a try today by download the latest code from github at: https://github.com/npgsql/Npgsql/archive/master.zip

Francisco Figueiredo Jr. said...

Hi Piotr Trychta.

This was a little error in the assembly building. We already uploaded a new version to nuget. Please, check it out and let me know if it worked for you.

Thanks for feedback.

Piotr Trychta said...
This comment has been removed by the author.
Piotr Trychta said...
This comment has been removed by the author.
Piotr Trychta said...

Npgsql and EF 4.3.1 works for me.

S Clay Turner said...

Thank you for all of your great work on Npgsql. I pulled and compiled latest source today from the git repository, and then referenced all assemblies in the EntityFramework project bin (release-net45). I'm trying to go code-first with EF6 to pg 9.3, but get the following error when enabling migrations.

Type is not resolved for member 'Npgsql.NpgsqlException,Npgsql, Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.

I don't think the config is off, but am still a bit unclear on whether or not database creation is even supported. My database does not yet exist.

S Clay Turner said...

Scratch the prior questions. Simply adding the compiled assemblies to the GAC solved the type issue. I also understand that i need to create the db first before an initial migration. However, with that first migration of domain entities, I get the following exception. Any insight would be extremely helpful. Lateset builds of Npgsql and Npgsql.EntityFramework are both referenced.

"No MigrationSqlGenerator found for provider 'Npgsql'. Use the SetSqlGenerator method in the target migrations configuration class to register additional SQL generators."

Francisco Figueiredo Jr. said...

Hi, Clay Turner.

We still don't have support for database migration or creation. But there is a pull request for that! Check out https://github.com/npgsql/Npgsql/pull/91 and give it a try. Let us know if it worked for you. This will be very helpful.

Thanks in advance.

Rose Apps said...
This comment has been removed by the author.
Piotr Trychta said...
This comment has been removed by the author.
SevZ said...


I'm trying to "Update Model From Database" with VS 2012, PG 9.0.8 and Npgsql and EF 5.0.0.

I see this error:

Microsoft Visual Studio
An error occurred while connecting to the database. The database might be unavailable. An exception of type 'System.Data.ProviderIncompatibleException' occurred. The error message is: 'The store data provider failed to return information for the StoreSchemaDefinition request. See the inner exception for details.

The inner exception caught was of type 'System.ArgumentNullException', with this error message: 'Value cannot be null.

Parameter name: input'.'.

Despite the message saying that the db might be unavailable, I'm sure that the connection to postgres is being correctly established because I see it in the PG logs.

Can you help out? Where can I look to troubleshoot this?


Francisco Figueiredo Jr. said...

Hi, Sev!

Unfortunately Npgsql still doesn't have support for Update Model from Database. We are working on this support on github: https://github.com/npgsql/Npgsql/pull/91

Sorry for the inconvenience.

david antenor said...

hey sevz,
In my case, S Clay Turner's solution also solved that error message. I was able to generate the edmx model using Visual Studio 10, Postgres 9.3,Npgsql

"Simply adding the compiled assemblies to the GAC solved the type issue"

you can try if it works.

SevZ said...

David Antenor,

Thanks for your input!

I found that Visual Studio 2013 (v12) has an issue creating schema from database when 3rd party providers are used.


So I guess I have to continue to use Visual Studio 2012 to generate schema from database.


david antenor said...

I used visual studio 2010 rather.
[Npgsql.Provider2] + [Npgsql-] projects in debugging mode to launch a new visual studio instance. compiled the assemblies (in Debug4 folder) again using the gacutil. from there I was able to Update from Database (existing postgres db). I guess it still doesn't work on newer versions of visual studio. I'm still new to this

Alberto Sánchez said...


We are currently in the process of migrating data to PostgreSQL Databases SQLServer

We are currently using the " Npgsql 2.0.12 " version of our system and we are detecting performance problems, as we have a situation similar to this : https://groups.google.com/forum/m/#!topic/npgsql-dev/Pl_-FfUQZ8I

Our systems have hundreds of simultaneous connections between 400 connections on less traffic days and 800 connections on more traffic days, we expect that this will increase.

When we tested yields pgbench work as expected.

These are the tests in a production server :

pgbench emp_bra_lctr -C- c 700- j 50 - T 60 -U postgres
starting vacuum ... end .
transaction type: TPC- B ( sort of)
scaling factor : 1
query mode: single
number of clients: 700
number of threads: 50
duration: 60 s
number of transactions actually processed : 8673
tps = 135.914877 (including connections Establishing )
tps = 138.361335 (excluding connections Establishing )

The configuration server is:
work_mem = 300MB
shared_buffers = 10GB # (change requires restart)
temp_buffers = 2GB
maintenance_work_mem = 2GB
max_connections 1000

Our server have a Linux Ubuntu 12.04 and the hardware is:

12 Cores

But using the " Npgsql 2.0.12 " our / s connector server does not work as expected, It is very slow when traffic up.

The question: In release 2.1 you have solved this problem? If not. Where I can check in the sources? In the ConnectionPool ?