The Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql.EntityFramework' registered in the application config file for the ADO.NET provider

2,248 views
Skip to first unread message

Salwa

unread,
May 12, 2015, 7:55:10 AM5/12/15
to npgsq...@googlegroups.com
I'm struggling with this issue for more than 2 days now when I try to add a controller to my Asp.net MVC 3 Project (VS 2010).
I installed EF 6.1.3, Npgsql 2.2.5, and Npgsql.EntityFramework using Nuget. I also registered Npgsql to GAC + added Npgsql provider to machine.config, etc.
Now when trying to add a controller and after choosing  : "Controller with read/write actions and views, using Entity Framework" template, I get the following error :

Unable to retrieve metadata for 'MvcApplication.Models.centredevote'.
The Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql.EntityFramework' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' could not be loaded.
Make sure that the assembly-quallified name is used and that the assembly is available to the running application.
See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

I googled the error and came across a post stating the same issue.. The solution mentioned was to add Npgsql.EntityFramework using Nuget, but I have already Npgsql.EntityFramework installed.. The dll files are present in the references section in visual studio too.. So I really don't know what's wrong.
Any help is much appreiciated and thanks in advance!

Here's my web.config file :

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<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="ApplicationServices" connectionString="data
source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
Instance=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
  -->

 
<connectionStrings>
 
<add name="electionscasaEntities" connectionString="metadata=res://*/Models.ElectionsCasa.csdl|res://*/Models.ElectionsCasa.ssdl|res://*/Models.ElectionsCasa.msl;provider=Npgsql;provider
 connection
string=&quot;PORT=5432;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE=2.2.5.0;DATABASE=mydb;HOST=localhost;USER
 ID=sde;"
providerName="System.Data.EntityClient" />
 
</connectionStrings>
 
<appSettings>
   
<add key="webpages:Version" value="1.0.0.0" />
   
<add key="ClientValidationEnabled" value="true" />
   
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
 
</appSettings>
 
<system.web>
   
<compilation debug="true" targetFramework="4.0">
     
<assemblies>
       
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     
</assemblies>
   
</compilation>
   
<authentication mode="Forms">
     
<forms loginUrl="~/Account/LogOn" timeout="2880" />
   
</authentication>
   
<membership>
     
<providers>
       
<clear />
       
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
     
</providers>
   
</membership>
   
<profile>
     
<providers>
       
<clear />
       
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
     
</providers>
   
</profile>
   
<roleManager enabled="false">
     
<providers>
       
<clear />
       
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
       
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
     
</providers>
   
</roleManager>
   
<pages>
     
<namespaces>
       
<add namespace="System.Web.Helpers" />
       
<add namespace="System.Web.Mvc" />
       
<add namespace="System.Web.Mvc.Ajax" />
       
<add namespace="System.Web.Mvc.Html" />
       
<add namespace="System.Web.Routing" />
       
<add namespace="System.Web.WebPages" />
     
</namespaces>
   
</pages>
 
</system.web>
 
<system.webServer>
   
<validation validateIntegratedModeConfiguration="false" />
   
<modules runAllManagedModulesForAllRequests="true" />
 
</system.webServer>
 
<runtime>
   
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     
<dependentAssembly>
       
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
       
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
     
</dependentAssembly>
     
<dependentAssembly>
       
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
       
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
     
</dependentAssembly>
     
<dependentAssembly>
       
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
       
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
     
</dependentAssembly>
     
<loadFromRemoteSources enabled="true" />
     
<dependentAssembly>
       
<assemblyIdentity name="System.Data.Entity" publicKeyToken="b77a5c561934e089" culture="neutral" />
       
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
     
</dependentAssembly>
     
<dependentAssembly>
       
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral" />
       
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
     
</dependentAssembly>
   
</assemblyBinding>
 
</runtime>
 
<entityFramework>
   
<!--
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory> -->

   
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
   
<providers>
     
<!--
 
     <provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices,
EntityFramework.SqlServer" />-->

       
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
   
</providers>
 
</entityFramework>
 
<system.data>
   
<DbProviderFactories>
     
<remove invariant="Npgsql" />
     
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
   
</DbProviderFactories>
 
</system.data>
</configuration>

Francisco Figueiredo Jr.

unread,
May 12, 2015, 10:55:46 AM5/12/15
to Salwa, npgsql-help

Did you add mono.security.dll  to gac as well? Npgsql 2.2.5 needs it.

I hope it helps

--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/b8f76359-539f-43e1-bd1f-7a6493afcbbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Salwa

unread,
May 12, 2015, 10:59:37 AM5/12/15
to npgsq...@googlegroups.com, fran...@npgsql.org
Yes I have added mono.security.dll as well.. But still getting the same error !
Any thoughts?
Reply all
Reply to author
Forward
0 new messages