如何将PostgreSql与EntityFramework 6.0.2集成?

时间:2013-12-17 07:46:07

标签: c# postgresql entity-framework-6

我收到以下错误

  

'实例'实体框架提供程序类型的成员   ' Npgsql.NpgsqlServices,Npgsql,Version = 2.0.14.2,Culture = neutral,   公钥= 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

由于

1 个答案:

答案 0 :(得分:1)

查看此问题:Entity Framework 6 with Npgsql

它有指向让它工作。我希望它有所帮助。