我試圖創建一個小的POC爲我的老闆約12 Npgsql的EF6和的混合, 創建一個新的項目在Visual Studio中創建 示例數據庫 創建相應的類和的DbContext 然而,每當我嘗試並使用EF訪問我收到了如下因素錯誤的數據庫:一起使用npgsql 12和ef 6 - 任何人都可以成功嗎?
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-support-added-to-npgsql.html
的支持,但是我似乎無法得到它的工作, 我的App.C onfig文件看起來像這樣:
<?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>
任何幫助將不勝感激!
花了一段時間弄清楚它自己 - 必須進入包管理器控制檯並使用「Install-Package npgsql -Pre」,還有di d在entity-framework上,感謝您確認我應該只爲npgsql做到這一點。 –
從Zip文件在這裏使用NpgSql(2.0.13.91)確實不會拋出DbProvider異常,但它會在查詢中拋出其他幾個奇怪的異常。 EF6和NpgSql 2.0.14.3現在可在nuget上使用,而無需使用-pre。 但我仍然回到上面提到的相同例外。 EF和NpgSql穩定版本都已發佈,必須有解決方案! –