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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With