Entity Framework 6.1.1 and Npgsql 2.2.3: Could not find a compatible Entity Framework database provider

I am working on a project using EntityFramework 6.1.1 and npgsql 2.2.3 in an update to Visual Studio 2012 4. For this, I installed npgsl using the supplied installation and installed the nuget packages “Npgsql” and “Npgsql for Entity Framework” (and, of course, "EntityFramework" itself).

Every thing was in order: I could successfully access my database for a while - until at some point everything “exploded”.

This is a story of events:

  • Fixing compiler errors after a major code update, I came across these error messages:
    • "failed to load npgsl.EntityFrameworkLegacy assmbly" (I did not set a link to this assembly)
    • Unable to find a whole bunch of metadata file "xxx" "errors in which" xxx "refers to all my own builds of projects
  • I found possible solutions to problems with metadata files - for example, deleting a .suo file, checking the build order of a project, etc. None of them fixed the problem. So I deleted the .edmx file (and therefore all automatically generated database access files) from my project. This fixed the "Metadata File" problems - of course, introducing "unresolved characters."
  • " ADO.NET" , . PostgreSQL, . PostgreSQL-, . " " Visual Studio: PostgreSQL.
  • npgsql . " ADO.NET" PostgreSQL. : " Entity Framework, Entity Framework, , [...]". .

:

  • :
    • EntityFramework 6.1.1 .NET 4.5
    • EntityFramework.SqlServer 6.1.1 .NET 4.5
    • Npgsql 2.2.3 .NET 4.5
    • Npgsql.EntityFramework 2.2.3 .NET 4.5
  • app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
    </providers>
  </entityFramework>
</configuration>
  • machine.config(32bit 64bit):
  <system.data>
    <DbProviderFactories>
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
  </system.data>

, . .

, , , ?

, , ?

+4

Source: https://habr.com/ru/post/1568322/


All Articles