繁体   English   中英

Npgsql Entityframework-无法看到ADO.net实体数据模型的Postgres提供程序

[英]Npgsql Entityframework - Can't see Postgres provider for ADO.net Entity Data Model

我正在尝试将Postgres数据库连接到EDMX设计器。

我已经按如下所述安装了EntityFrameowrk6.npgsql块模块: http ://www.npgsql.org/ef6/index.html(数据库已经具有uuid-ossp扩展名)

然后,按照下面的说明安装扩展包: http : //www.npgsql.org/doc/ddex.html

最后,我已将npgsql模块更新为v3.2.1,以匹配集成文档中建议的扩展版本。

我可以使用Visual Studio的服务器浏览器连接到数据库。

完成此操作后,我将一个ado.net实体数据模型添加到我的项目中,但是他唯一可用的提供者是Microsoft sql的提供者。 看不到Postgres!

我正在运行Visual Studio Community 2017,它是最新的,并且安装的唯一其他扩展是AnkhSVN。 这是当前为.net 4.5.1配置的C#项目(但我很高兴并愿意更改目标框架以使事情正常进行!)

我的项目中唯一的Nuget软件包是上述软件包及其依赖性。

大量的搜索结果导致各种教程告诉我基本上执行上述操作,或者人们在app.config中添加了元素(我已经尝试过并失败了,然后还原了),而npgsql文档明确指出了您不需要做的事情。

任何帮助,不胜感激!

编辑:这是我目前的App.Config。

<?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" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.1.0" newVersion="3.2.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

原来我遇到的问题是,添加NuGet东西后我没有重建项目/解决方案。 主要是由于我用Postgre替换了旧的SQL EF实现,并且由于无数的引用丢失而无法构建。

这里的问题表明重建应该发生: Entity Framework 6.1.1和Npgsql 2.2.3:找不到兼容的Entity Framework数据库提供程序

因此,我注释掉了大部分代码,对其进行了重新构建,并且提供程序已出现在我期望的位置。

崩溃的Visual Studio(BOO嘶!),但是这是一个单独的问题。

我希望这对一些可怜的灵魂有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM