Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

incompatible versions of Npgsql and EntityFramework6.Npgsql

Tags:

npgsql

Without properly setting up the project, it will always be seen an error like this:

Could not load file or assembly 'Npgsql, Version = 3.1.2.0, Culture = neutral, PublicKeyToken = 5d8b90d52f46fda7' or one of its dependencies. The assembly's manifest definition located not match the assembly reference. (Exception from HRESULT: 0x80131040)

After using the AsmSpy, I noticed that the problem is in "EntityFramework6.Npgsql" that does not recognize the newer versions of Npgsql, as shown in the following figure:

Meu projeto personalizado reconhece a última versão, menos o "EntityFramework6.Npgsql"

My own DLL recognizes the latest version, except "EntityFramework6.Npgsql"

like image 242
Dhiogo Acioli Avatar asked Jul 14 '16 15:07

Dhiogo Acioli


1 Answers

For some reason, EF6.Npgsql 3.1.1 was compiled against Npgsql 3.1.2, even though the nuget takes a dependency against 3.1.0. I opened an issue for this.

However, in a more general way, you need a binding redirect to allow EF6.Npgsql to run against a newer version of Npgsql (e.g. 3.1.6), otherwise it requires the exact version it was compiled against. Ordinarily VS is supposed to automatically add the needed redirect into your App.config, see https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx. I've tested in a virgin project and this works: Installing EF6.Npgsql 3.1.1 and then Npgsql 3.1.6 results in the correct binding redirect to appear in App.config, redirecting to Npgsql 3.1.6 - and everything works fine.

like image 140
Shay Rojansky Avatar answered Oct 25 '22 21:10

Shay Rojansky