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

entity-framework-6 npgsql

Question

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

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

Thx!

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