使用npgsql 12和EF 6一起 - 已经有人成功了呢? [英] Using npgsql 12 and ef 6 together - have anyone succeeded with it?

查看:384
本文介绍了使用npgsql 12和EF 6一起 - 已经有人成功了呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个小的POC为我的老板介绍npgsql 12 EF6的混合动力,
创建了Visual Studio的
一个新项目创建一个示例数据库
创建了相应的类和的DbContext
然而,每当我尝试使用EF访问我收到了如下因素错误的数据库:

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:

在'例如Npgsql.NpgsqlFactory,Npgsql'实体框架提供程序类型
的成员,版本= 2.0.12.0,文化=中立,
公钥= 5d8b90d52f46fda7'没有返回
从继承的对象System.Data.Entity.Core.Common.DbProviderServices。
实体框架供应商必须从这个类和
实例成员必须返回供应商的单一实例继承。
这可能是因为供应商不支持实体框架6
或更高版本;看到 http://go.microsoft.com/fwlink/?LinkId=260882 了解
。信息

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.

我知道它应该在相当一段时间的支持,现在
http://fxjr.blogspot.co.il/2013/06/initial-ef-6 - 支持加至npgsql.html

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

不过,我似乎无法得到它的工作,
我App.config文件看起来是这样的:<?/ p>

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!

推荐答案

现在它仅适用于Npgsql的 http://pgfoundry.org/frs/download.php/3494/Npgsql2.0.13.91-bin-ms.net4.5Ef6.zip
和必须更改

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" />

这篇关于使用npgsql 12和EF 6一起 - 已经有人成功了呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆