I\'m trying to create a small POC for my boss about the hybrid of npgsql 12 and ef6, created a new project on visual studio created a sample database created the correspondi
I got it EF6 and Npgsql to work following:
Entity Framework 6 with Npgsql
PMC> Install-Package EntityFramework
(should give you version 6)
PMC> Install-Package Npgsql.EF6 -Pre
(should give you 2.0.12-pre4)
And these go into App.config
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description ="Data Provider for PostgreSQL"
type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="PostgreSQL"
providerName="Npgsql"
connectionString="Server=asdf;Port=5432;User Id=asdf;Password=asdf;Database=asdf;enlist=true" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="Npgsql"
type="Npgsql.NpgsqlServices, Npgsql" />
</providers>
</entityFramework>
Now it only works with last beta version of Npgsql http://pgfoundry.org/frs/download.php/3494/Npgsql2.0.13.91-bin-ms.net4.5Ef6.zip And you must change
<provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql" />
to
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql" />
This is a template App.config which you can use as a starting point.
<xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"></provider>
</providers>
<defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
</configuration>
Note that you will need the Npgsq.EntityFramework.dll 2.1.0 assembly as well as Npgsql 2.1.0 Both are currently in Beta and you can find them at Nuget or http://downloads.npgsql.org or in our github project page: https://github.com/npgsql/Npgsql/releases.
I just wrote a blog post about it: http://fxjr.blogspot.com.br/2014/02/using-entity-framework-6-with-npgsql-210.html
I hope it helps.
This is how I got it working :
First install the package
Install-Package Npgsql.EF6 -Pre
And after that add this line to the web.config
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>