1

Hi I am trying to use EF6 with npsql under Asp.net 5. I am using a simple console (asp.net5) for testing and a separate class lib (.net 4.5) for the data access as a simple test enviroment. Have installed EF6 using nuget EntityFramework6.Npgsql. Have also removed .net core dependencies from project.json file. The problem i keep on getting the following error.

An exception of type 'System.NotSupportedException' occurred in EntityFramework.dll but was not handled in user code

Additional information: Unable to determine the provider name for provider factory of type 'Npgsql.NpgsqlFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.

It seems to have trouble with the provider name for 'Npgsql.NpgsqlFactory'. But the provider name in the configuration is set. May be it needs to be set when it was compiled. Any ideas?

the app.config file is as follows

<?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" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<providers>
<provider invariantName="Npgsql.NpgsqlFactory" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"></provider>
</providers>
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
</configuration>

Any help will be much appreciated. Many thanks.

Farjad
  • 257
  • 4
  • 9

1 Answers1

1

You are missing the complete assembly information for npgsql in your configuration. Please, check this answer for more information about it and the complete information:

https://stackoverflow.com/a/35440114/246097

I hope it helps.

Community
  • 1
  • 1
Francisco Junior
  • 1,986
  • 18
  • 25