[英]How do I fix a DbProviderServices inheritance error for a MVC3 project on Mono 3.0.3, Entity Framework 6 Beta2 and Npgsql?
I have a MVC3 project targeting .net 4.5 running on Mono to the point where the only thing that is failing is the connection from Entity Framework to PostgreSQL. 我有一个MVC3项目,目标是在Mono上运行.net 4.5,唯一失败的是从Entity Framework到PostgreSQL的连接。
I have an almost identical project working in VS 2012 with MVC4, EF6, Postgres. 我有一个几乎相同的项目在VS 2012与MVC4,EF6,Postgres一起工作。
I am getting the following error: 我收到以下错误:
System.InvalidOperationException The 'Instance' member of the Entity Framework provider type 'Npgsql.NpgsqlFactory, Npgsql' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'.
System.InvalidOperationException实体框架提供程序类型“Npgsql.NpgsqlFactory,Npgsql”的“实例”成员未返回继承自“System.Data.Entity.Core.Common.DbProviderServices”的对象。 Entity Framework providers must extend from this class and the 'Instance' member must return the Singleton instance of the provider.
实体框架提供程序必须从此类扩展,并且“实例”成员必须返回提供程序的Singleton实例。
Am I missing something in configuration or is this not going to work? 我在配置中遗漏了什么,或者这不起作用?
<!--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" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
And ... 而......
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql">
</provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
Mono ASP.net version string ... 单声道ASP.net版本字符串......
Version Information: 3.0.3 (master/39c48d5); ASP.NET Version: 4.0.30319.17020
You need a PostgreSQL connector for EF6 because of the changes. 由于更改,您需要一个用于EF6的PostgreSQL连接器。 you can read more about the situation here:
你可以在这里阅读更多有关情况的信息:
http://entityframework.codeplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6 http://entityframework.codeplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6
I fixed this error. 我修复了这个错误。
Change 更改
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql"></provider>
</providers>
</entityFramework>
TO 至
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql"></provider>
</providers>
</entityFramework>
Change you entityFramework section config to this: 将entityFramework section config更改为:
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
PS:I using Npgsql version 2.1.0.0 PS:我使用Npgsql版本2.1.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.