Entity Framework Data Provider error when using a custom Data Provider with GAC assemblies

Today I ran an Entity Framework migration, which resulted in an exception. Unfortunately, because I am connecting to a Postgres database instance using Npgsql I get the following error instead of the actual exception.

Type is not resolved for member ‘Npgsql.NpgsqlException,Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’.

To fix this and see the actual exception I had to add the Npgsql.dll assembly into the GAC (C:\Windows\assembly). However I received yet another error after doing this.

Failed to find or load the registered .Net Framework Data Provider.

This confused me for a little bit, until I realised that it meant that the assembly was most likely missing from the bin directory of my project. Sure enough I looked there and it was gone. Adding it back there fixed the second error and I finally got to see the real exception.

It’s been a while since I’ve had problems caused by the GAC, not since working with custom SSIS components.

Advertisements
Entity Framework Data Provider error when using a custom Data Provider with GAC assemblies