簡體   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