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:
My own DLL recognizes the latest version, except "EntityFramework6.Npgsql"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With