Skip to main content

Initial Npgsql2 provider factory support added to cvs

UPDATE: Thomas Burkhart sent me a mail telling me that this configuration syntax doesn't work on ms.net 2.0. This is the version which works:

<?xml version="1.0" encoding="iso-8859-1" ?>
<configuration>

<system.data>
<DbProviderFactories>

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

</DbProviderFactories>
</system.data>

</configuration>


Thomas said that "the tags are case sensitive and the must be outside any <applicationSettings>"


Thank you Thomas for your feedback which, for sure will help others to get their configuration up and running. I will check with Mono guys to see why my original configuration worked.




Hi all!

Today I committed an initial support for provider factory to Npgsql2.

This will allow ado.net 2.0 users to work with Npgsql using ado.net generic coding.

In order to use it, you have to add the following xml config in your machine.config or yourapp.exe.config file:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<appsettings>

<system.data>
<dbproviderfactories>

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


P.S.: Sorry for indentation lacking. I don't know how to add it on blogger :(

Note that this is the full contents of a yourapp.exe.config file. If you are changing the machine.config file, just add the "add name=..." section.

The key elements here are the invariant name which will be used in your application when returning the provider factory. In this case it is defined as "Npgsql". But you can specify whatever you want.


That's it! If everything is ok, you will be able to write some code like that, to connect to postgresql:


using System;
using System.Data;
using System.Data.Common;


public class c
{
public static void Main(String[] args)
{

DbProviderFactory factory = DbProviderFactories.GetFactory("Npgsql");

DbConnection conn = factory.CreateConnection();

conn.ConnectionString = "Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;";

conn.Open();

conn.Close();


}
}


Enjoy!


P.S.: Npgsql2 code is found in Npgsql2 cvs module. See here for more info about how to get it.

Warning: This is a very early code, so bugs still exist and there are things missing. Basic functionality should work ok.



Comments

Anonymous said…
Hi Francisco, I've been using the cvs version and it is working great. One note, on the .net20 framework I found you need to put the <system.data> information in the <configuration> section, outside of the <appSettings>.

Great work, cheers!
Dan
Anonymous said…
Hi Francisco,
many thanks for your good work. I downloaded the CVS version, compiled it, made the entries in machine.config and it seems to work quite well.

Do you have any intention to build a configuration utility (DbProviderConfigurationHandler?) so that you can connect to it using the Server Explorer in Visual Studio?

Kind regards
Trevor D'Arcy-Evans
Anonymous said…
Boa tarde francisco. Baixei sua versão do cvs e estou usando aqui seu provider com o factory no .net 2.0.
Mas acabei me deparando com um problema. Tenho um banco postgres em UTF8, e ao tentar salvar uma string com acentos ele diz que não aceita a sequencia de bytes:
ERROR: 22021: invalid byte sequence for encoding "UTF8": 0xe97374
A sequencia que mandei foi "Téste Ç" (sem as aspas)

Chequei o Request.ContentEncoding do aspnet e ele está em UTF8.

Pode me dar alguma informação sobre este problema?
Aguardo seu contato.
junalmeida@msn.com; junalmeida@gmail.com
Anonymous said…
For people having the same problem as Marcos Jr. ("invalid byte sequence" when trying to insert accented characters in UTF8 encoded databases):

Just create your database with the default encoding (SQL_ASCII) and you should be able to insert and retrieve accented characters fine :)

Don´t know the logic behind this (hints someone?), but worked like a charm for me.
alex said…
Then we will go into the lock and in a few minutes we shall be on the adderall lake.. After considerable whispering between Jane and her mother, the former withdrew, and sent in by the Irish girl a waiter with a basket of soda biscuit, a thyroid pitcher of water, and some glasses.. But on the amoxicillin first appearance of my double--whom I sent on this fatal Monday to the fifth meeting--he was the sixty-seventh man who entered the room.. Atrocious! she exclaimed. clonazepam. Let us, however, keep to the fact--this is the key to the theory of repression--that the second system is capable of occupying an idea only when it is in amoxicillin position to check the development of pain emanating from it.. Lick him! Lick him! exclaimed Buller. celexa. Her daughter having completed her education at the best boarding-school in fluoxetine Philadelphia, and her son being about to graduate at Princeton, the mother had planned with her children a tour to Niagara and the lakes, returning by way of Boston.. It compels us to pursue the lisinopril inner meaning of the dream in these productions.. Got a pencil? He produced the bit of cardboard; Ross fished up a chewed stump of lead pencil, took it in cold, stiff fingers, and disfigured the square with eccentric thyroid scribblings.. All manifestations disappeared as a result of a lengthy sojourn in the country, bodily exercise, and the return lidoderm of physical strength after the termination of the period of puberty.. She's just outside, meanderin' in the road--kinder shy, ye celebrex know, at first.. His parents came home late and went to bed while viagra he was feigning sleep.. The track synthroid couldn't have been in better condition.. Let pretend we ain't here and he'll go away, motrin breathed Abner.. And I had not been at work a year before I found I was living two lives, one real and one merely functional--for two sets of people, one my parish, whom I loved, fioricet and the other a vague public, for whom I did not care two straws...
alex said…
Then we will go into the lock and in a few minutes we shall be on the clindamycin lake.. After considerable whispering between Jane and her mother, the former withdrew, and sent in by the Irish girl a waiter with a basket of soda biscuit, a acetaminophen pitcher of water, and some glasses.. But on the claritin first appearance of my double--whom I sent on this fatal Monday to the fifth meeting--he was the sixty-seventh man who entered the room.. Atrocious! she exclaimed. oxycontin. Let us, however, keep to the fact--this is the key to the theory of repression--that the second system is capable of occupying an idea only when it is in allegra position to check the development of pain emanating from it.. Lick him! Lick him! exclaimed Buller. lyrica. Her daughter having completed her education at the best boarding-school in effexor Philadelphia, and her son being about to graduate at Princeton, the mother had planned with her children a tour to Niagara and the lakes, returning by way of Boston.. It compels us to pursue the phentermine inner meaning of the dream in these productions.. Got a pencil? He produced the bit of cardboard; Ross fished up a chewed stump of lead pencil, took it in cold, stiff fingers, and disfigured the square with eccentric soma scribblings.. All manifestations disappeared as a result of a lengthy sojourn in the country, bodily exercise, and the return fluoxetine of physical strength after the termination of the period of puberty.. She's just outside, meanderin' in the road--kinder shy, ye avandia know, at first.. His parents came home late and went to bed while calcium he was feigning sleep.. The track phentermine couldn't have been in better condition.. Let pretend we ain't here and he'll go away, zithromax breathed Abner.. And I had not been at work a year before I found I was living two lives, one real and one merely functional--for two sets of people, one my parish, whom I loved, lexapro and the other a vague public, for whom I did not care two straws...
alex said…
Then we will go into the lock and in a few minutes we shall be on the evista lake.. After considerable whispering between Jane and her mother, the former withdrew, and sent in by the Irish girl a waiter with a basket of soda biscuit, a lithium pitcher of water, and some glasses.. But on the diflucan first appearance of my double--whom I sent on this fatal Monday to the fifth meeting--he was the sixty-seventh man who entered the room.. Atrocious! she exclaimed. diovan. Let us, however, keep to the fact--this is the key to the theory of repression--that the second system is capable of occupying an idea only when it is in vicodin position to check the development of pain emanating from it.. Lick him! Lick him! exclaimed Buller. acyclovir. Her daughter having completed her education at the best boarding-school in diclofenac Philadelphia, and her son being about to graduate at Princeton, the mother had planned with her children a tour to Niagara and the lakes, returning by way of Boston.. It compels us to pursue the viagra inner meaning of the dream in these productions.. Got a pencil? He produced the bit of cardboard; Ross fished up a chewed stump of lead pencil, took it in cold, stiff fingers, and disfigured the square with eccentric phentermine scribblings.. All manifestations disappeared as a result of a lengthy sojourn in the country, bodily exercise, and the return allopurinol of physical strength after the termination of the period of puberty.. She's just outside, meanderin' in the road--kinder shy, ye celexa know, at first.. His parents came home late and went to bed while naprosyn he was feigning sleep.. The track heparin couldn't have been in better condition.. Let pretend we ain't here and he'll go away, calcium breathed Abner.. And I had not been at work a year before I found I was living two lives, one real and one merely functional--for two sets of people, one my parish, whom I loved, calcium and the other a vague public, for whom I did not care two straws...
alex said…
.. .. .. .. .. .. .. .. .. .. .. .. .. .. ...
alex said…
.. .. .. .. .. .. .. .. .. .. .. .. .. .. ...
Anonymous said…
does someone know how to make this work also with the server explorer in Visual Studio (previously asked by trevor d'arcy-evans).
BitStream said…
Just for reference, if you happen to come across this post and add the xml snippet required, you must make sure the version number in the snippet matches the version you have. As of this posting, Npgsql2 beta2 has a version of 1.98.2.0

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! :)

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

Initial EF-6 support added to Npgsql

In my last post , I said there is a pull request by Pēteris Ņikiforovs to add support for EF-6 to Npgsql. Yesterday, I merged this pull request to the master branch of Npgsql . With this merge, Npgsql has officially initial support for EF-6! How to compile For now, in order to compile Npgsql to use EF-6, you have to open the solution file NpgsqlEF6.sln. Later,  as suggested by Pēteris Ņikiforovs , the idea is that we create a new configuration inside main project solution instead of maintain 2 separated projects. Another thing you will need to compile Npgsql is the latest release of EntityFramework assembly through NuGet: PM> Install-Package EntityFramework -Pre That's it! Now you will be able to play with Npgsql and EF-6. Check out my previous post about how to use Npgsql with EntityFramework. I'd like to thank Pēteris Ņikiforovs for his patch. And maxbundchen for his patch about Open/Close events needed for EF-6. Please, give it a try and let me know how it