Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
Hi.

I'm trying to use Npgsql Entity Framework in a web application MVC (C#) with:

Visual Studio 2017 version 15.4.4
.Net Framework 4.6.1
Npgsql 3.2.5.0
Npgsql.EntityFrameworkCore.PostgreSQL 2.0.0.0
Npgsql.EntityFrameworkCore.PostgreSQL.Design 2.0.0.0

And in web.config file:

Connection String:
<add name="DefaultConnection" connectionString="Server=127.0.0.1;Port=5432;Database=mydatabase;User Id=myuser; Password=mypassw;" providerName="Npgsql" />

Default Connection:
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql.EntityFramework" />

Provider:
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />

Provider factory:
<system.data>
<dbproviderfactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />



But VS send me this error on runtime:

Se produjo la excepción System.InvalidOperationException.
HResult=0x80131509
Mensaje = No se puede cargar el tipo de proveedor de Entity Framework 'Npgsql.NpgsqlServices, Npgsql.EntityFramework' registrado en el archivo de configuración de la aplicación para el proveedor de ADO.NET con el nombre invariable 'Npgsql'. Asegúrese de que se usa el nombre calificado con el ensamblado y que el ensamblado está disponible para la aplicación en ejecución. Vea http://go.microsoft.com/fwlink/?LinkId=260882 para obtener más información.
Origen = <No se puede evaluar el origen de la excepción>
Seguimiento de la pila:
<No se puede evaluar el seguimiento de la pila de excepciones>

Could someone tell me what I'm doing wrong or what I need to configure?

Thanks in advance


What I have tried:

I have searched for articles that talk about this problem but I have not found a solution
Posted
Comments
Richard Deeming 1-Dec-17 14:28pm    
Searching for the English translation of the error messages returns quite a few results.

Looking at this GitHub issue[^] suggests you're missing the culture and public key token from the provider registration:
<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>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900