2013-12-17 26 views
4

我收到以下錯誤如何將PostgreSql與EntityFramework 6.0.2集成?

實體框架提供程序類型 的「實例」成員「Npgsql.NpgsqlServices,Npgsql的,版本= 2.0.14.2,文化=中立, 公鑰= 5d8b90d52f46fda7」未返回 從「System.Data.Entity.Core.Common.DbProviderServices」繼承的對象。 實體框架提供者必須繼承此類,並且 「實例」成員必須返回提供者的單例實例。 這可能是因爲提供程序不支持實體框架6 或更高版本;有關更多 的信息,請參閱http://go.microsoft.com/fwlink/?LinkId=260882

任何一個可以幫助我

這裏是我的app.config文件

<?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" /> 
    </configSections> 
    <connectionStrings> 
    <add name="CacsLocal" connectionString="Server=localhost;Database=Kappa;User Id=postgres; Password=xyz;" providerName="Npgsql" /> 
    <add name=" CacsCentral" connectionString="Server=localhost;Database=KPT1;User Id=postgres; Password=insane1234;" providerName="Npgsql" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers>  
     <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql" /> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"></provider> 
    </providers> 
    </entityFramework> 
    <system.data> 
    <DbProviderFactories> 
     <add name="Npgsql Data Provider" invariant="Npgsql" description="Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql" /> 
    </DbProviderFactories> 
    </system.data> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
</configuration> 

我有Npgsql2版本2.0.14.2 實體框架6.0.2

,所有的包裝都通過包管理器通過以下命令安裝:

Install-Package Npgsql -Pre 
Install-Package EntityFramework -Pre 

感謝

+0

你在你的主項目(http://npgsql.projects.pgfoundry.org/)中有這個參考嗎? – Tico

+0

讓我檢查並重新執行 –

+0

有一件事,不要使用'-pre'版本。您可能會遇到一些不兼容問題。 – Tico

回答

1

退房這個問題:Entity Framework 6 with Npgsql

它具有指針得到它的工作。我希望它有幫助。

+0

我還用更多信息添加了另一個答案:http://stackoverflow.com/a/21839153/246097 –