JTew JTew - 1 year ago 131
C# Question

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.

I have an almost identical project working in VS 2012 with 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'. Entity Framework
providers must extend from this class and the 'Instance' member must
return the Singleton instance of the provider.

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=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->

And ...

<provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql">
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />

Mono ASP.net version string ...

Version Information: 3.0.3 (master/39c48d5); ASP.NET Version: 4.0.30319.17020

Answer Source

I fixed this error.


    <provider invariantName="Npgsql" type="Npgsql.NpgsqlFactory, Npgsql"></provider>


      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql"></provider>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download