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

entity-framework-6 npgsql

Question

2015 Visual Studio and.NET Framework

v6.1.3 of EntityFramework

3.1.0 of EntityFramework6.Npgsql

3.2.2 Npgsql

Even though the code works OK, I recently inherited a project that has an EDMX EF6 model that I am unable to view in Visual Studio due to 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."

These are the necessary app.config settings: -

<entityFramework>
   <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    </providers>
    <defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <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"/>
    </DbProviderFactories>
  </system.data>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.2.0" newVersion="3.2.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

The EDMX's Schema line appears as follows:-

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

Given that this project previously used SQL Server Compact 4, I am a little hesitant about the ProviderManifestToken="4.0" option. What would be the right answer in this case?

Can you think of anything wrong?

Thx!

1
1
10/9/2018 10:05:52 PM

Popular Answer

It seems that some modifications were manually made:-(

After much faffing (had issues with Data Connections and the EDM wizard https://github.com/npgsql/npgsql/issues/1445), I realised that the ProviderManifestToken should have been "9.6.2"; after making that adjustment to my EDMX, I am now able to access it in Visual Studio 2015.

The line in the EDMX file now resembles

<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">
0
5/9/2017 9:48:31 AM


Related Questions





Related

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