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 corresponding classes and the dbcontext
yet, whenever I try and use ef to access the database I receive the folowing error:
The 'Instance' member of the Entity Framework provider type
'Npgsql.NpgsqlFactory, Npgsql, Version=2.0.12.0, 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.
I know that it should be supported for quite some time now
http://fxjr.blogspot.co.il/2013/06/initial-ef-6-support-added-to-npgsql.html
however I can't seem to get it to work,
my App.Config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http:// go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!--<section name="entityFramework" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.12.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />-->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql" />
</providers>
</entityFramework>
<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="CoolestPGSoft"
connectionString="Server=127.0.0.1;Port=5432;Database=CoolestPGSoft;User Id=postgres;Password=********;"
providerName="Npgsql" />
</connectionStrings>
</configuration>
any help would be appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…