title: Unable to load Npgsql from a .NET class library xUnit test
body: <p>I'm learning a  bit of entity framework, and have started writing some test cases around it. </p>
  
  <p>I'm running into a problem whereby I am unable to load an assembly in the testcase, even though I can do so just fine (and the versions of the assemblies are the same) in the .net app itself.</p>
  
  <p>The error I'm getting:</p>
  
  <blockquote>
    <p>Message: System.IO.FileLoadException : Could not load file or assembly
    'Npgsql.EntityFrameworkCore.PostgreSQL, Version=2.0.2.0,
    Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its
    dependencies. Strong name signature could not be verified.  The
    assembly may have been tampered with, or it was delay signed but not
    fully signed with the correct private key. (Exception from HRESULT:
    0x80131045)</p>
  </blockquote>
  
  <h2>It works in a .net app</h2>
  
  <p>I began with getting a windows forms app running OK.
  This is using SimpleInjector, EF Core, Npgsql against a local postgres DB.
  I have got this to work just fine (DB creation, migrations, etc), with the DataContext (my DbContext) being loaded like so:</p>
  
  <pre><code>DbContextOptionsBuilder builder = new DbContextOptionsBuilder&lt;DataContext&gt;();
  DbContextOptions&lt;DataContext&gt; options = (DbContextOptions&lt;DataContext&gt;)builder.UseNpgsql(connectionString).Options;
              return new DataContext(options,NLog.LogManager.GetCurrentClassLogger());
  </code></pre>
  
  <p>I'm able to do a simple test of listing the Organizations from the DB. This is currently done in Form1.</p>
  
  <h2>So, onto the tests (where I'm having problems)</h2>
  
  <p>I added the same dependencies to a new "Testing" class library (EF Core, Npgsql, and so on).  I have a dependency on the EntityFrameworkTest project as well, so I can reference its models.</p>
  
  <p>I've simplified the test case (OrgDBTest) so that it attempts to create a context within it's constructor. I've done this so that I know my problem has nothing to do with SimpleInjector.</p>
  
  <p>My expectation is that the test would run, creating a DbContext in its constructor.  However I can't get it to load the assembly so that I can create my DbContext... so that I can continue creating/playing with tests.</p>
  
  <p>Code is here (pretty small):
  <a href="https://github.com/scornflake/entityframework-learn" rel="nofollow noreferrer">https://github.com/scornflake/entityframework-learn</a></p>
  
  <p>But lost, as it seems I'm doing the same thing in the testcase as I am in the app, yet assembly loading appears to be somehow different.</p>
  
  <p>Any ideas?</p>