【发布时间】:2014-01-04 21:20:31
【问题描述】:
我收到以下错误
实体框架提供程序类型的“实例”成员 'Npgsql.NpgsqlServices,Npgsql,版本=2.0.14.2,文化=中性, PublicKeyToken=5d8b90d52f46fda7' 没有返回一个对象 继承自“System.Data.Entity.Core.Common.DbProviderServices”。 实体框架提供者必须从这个类和 'Instance' 成员必须返回提供者的单例实例。 这可能是因为提供者不支持 Entity Framework 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
谢谢
【问题讨论】:
-
您的主项目中是否有[此引用](npgsql.projects.pgfoundry.org)?
-
让我检查并再做一次
-
一件事,不要使用
-pre版本。您可能会遇到一些不兼容问题。 -
使用此参考后我收到此错误“具有不变名称'NPGSQL'的 ADO.NET 提供程序未在机器或应用程序配置文件中注册”内部异常显示无法找到请求的。网络框架数据提供者。可能没有安装
-
卸载一切并重新安装。也可以使用 npgsql 论坛
标签: c# postgresql entity-framework-6