Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DbProviderFactory with Npgsql?

Tags:

I have a project which I'm trying to port from SQL Server to PostgreSQL. I've got almost everything done I believe except for I can not get DbProviderFactory to work with Npgsql.

Factory = DbProviderFactories.GetFactory("Npgsql"); 

yields

Unhandled Exception: System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider.

How do I fix this?

like image 241
Earlz Avatar asked Aug 02 '10 04:08

Earlz


People also ask

What is Npgsql driver?

Npgsql is an open source ADO.NET Data Provider for PostgreSQL, it allows programs written in C#, Visual Basic, F# to access the PostgreSQL database server. It is implemented in 100% C# code, is free and is open source.

How do I get Npgsql?

Official releases of Npgsql are always available on nuget.org. This is the recommended way to use Npgsql. We occasionally publish previews to nuget.org as well - these are generally quite safe for use, and can help us find issues before official packages are released.


1 Answers

Try defining a factory in your app.config:

<system.data>   <DbProviderFactories>     <add name="Npgsql Data Provider" invariant="Npgsql"          description="Data Provider for PostgreSQL"          type="Npgsql.NpgsqlFactory, Npgsql" />   </DbProviderFactories> </system.data> 

Via http://fxjr.blogspot.pt/2013/06/npgsql-code-first-entity-framework-431.html

like image 145
ANeves Avatar answered Sep 22 '22 16:09

ANeves