EF6 + NPGSQL - App.Config Settings - Provider with invariant name 'Npqsql' is either not registered etc. etc

entity-framework-6 npgsql


Visual Studio 2015 / .NET Framework 4.5

EntityFramework v6.1.3

EntityFramework6.Npgsql v3.1.0

Npgsql 3.2.2

I have inherited a project which contains and EDMX EF6 model which I cannot open in Visual Studio (although the code runs OK) possibly (??) because I am getting the following error: -

"Error 175: The ADO.NET provider with invariant name 'Npgsql' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details."

The relevant app.config settings look like this: -

      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    <defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
      <remove invariant="Npgsql"/>
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

The Schema line from the EDMX looks like this :-

<Schema Namespace="MyAppMOdel.Store" Alias="Self" Provider="Npgsql" ProviderManifestToken="4.0" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">

I am a bit wary of the ProviderManifestToken="4.0" setting since this project was previously using SQL Server Compact 4. What would be the correct value here?

Any ideas on what's wrong?


10/9/2018 10:05:52 PM

Popular Answer

It looks like someone had made some changes by hand:-(

After a lot of faffing (was having trouble with Data Connections & the EDM wizard https://github.com/npgsql/npgsql/issues/1445) I could see that the ProviderManifestToken should have been "9.6.2"; with that change made my EDMX I am now able to open it withing Visual Studio 2015.

The line in the EDMX file now looks like

<Schema Namespace="MyAppModel.Store" Provider="Npgsql" ProviderManifestToken="9.6.2" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
5/9/2017 9:48:31 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow