简体   繁体   English

如何修复Mono 3.0.3,Entity Framework 6 Beta2和Npgsql上的MVC3项目的DbProviderServices继承错误?

[英]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.

相关问题 实体框架的MVC继承:如何构建派生类型? - MVC Inheritance with Entity Framework: How do I scaffold a derived type? 如何在 MVC3 和实体框架上使用 Code First 将另一个表添加到我的数据库中? - How do I add another table to my database using Code First on MVC3 and Entity Framework? MVC3 &amp; Entity Framework 4 中的循环引用错误 - Cyclical reference error in MVC3 & Entity Framework 4 如何使用Entity Framework Core和Npgsql清理所有字符串输入? - How do I sanitize all my string inputs using Entity Framework Core and Npgsql? 实体框架6-Npgsql-连接字符串错误 - Entity Framework 6 - Npgsql - connection string error MVC3-如何在提交之前触发框架验证,以便它还显示必填字段的错误消息? - mvc3 - how do i trigger framework validation prior to submission so that it also displays error messages for required fields? 带有Npgsql的实体框架6 - Entity Framework 6 with Npgsql 在Visual Studio 2012或更高版本中使用Npgsql和Entity Framework的MVC4 - MVC4 using Npgsql and Entity Framework in Visual Studio 2012 or higher 当呈现的操作链接作为查询字符串返回时,如何解决MVC3的路由问题? - How do I fix a routing issue with MVC3 when rendered action links get returned as querystrings? 没有实体框架的MVC3多对多 - MVC3 Many to many without Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM