gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:47:10 25 4
gpt4 key购买 nike

我有一个针对 .net 4.5 的 MVC3 项目,它在 Mono 上运行,唯一失败的是从 Entity Framework 到 PostgreSQL 的连接。

我有一个几乎相同的项目,在 VS 2012 中使用 MVC4、EF6、Postgres。

我收到以下错误:

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'. Entity Framework providers must extend from this class and the 'Instance' member must return the Singleton instance of the provider.

我是不是在配置中遗漏了什么,或者这不会起作用?

<!--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 -->

还有……

  <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 Information: 3.0.3 (master/39c48d5); ASP.NET Version: 4.0.30319.17020

最佳答案

由于更改,您需要 EF6 的 PostgreSQL 连接器。你可以在这里阅读更多关于这种情况的信息:

http://entityframework.codeplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6

关于c# - 如何修复 Mono 3.0.3、Entity Framework 6 Beta2 和 Npgsql 上 MVC3 项目的 DbProviderServices 继承错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14513788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com