title: FileLoadException was unhandled by user code in asp identity code
body: <p>i have recently added Mysql to my asp project where i am using asp identity tables in order to save user data. I am saving user data in the local database created by the system automatically and have added the MySql database in order to manipulate and handle the data that i wish to use seperate from the users details. After running into to some errors with my <code>web.config</code> I have been left with this new error.</p>
  
  <p>After some research I have come to the conclusion that it may have something to do with packages however i feel that due to the circumstances of the error and the code that it is affecting that there may be some interference by my 2 separate databases. below i have posted the code around the error so the context of the code is there and have also outlined the line where the error is occurring. Furthermore i have included a copy of the error in full.</p>
  
  <p>The surrounding code:</p>
  
  <pre><code>namespace ComputingProjectwh.Models
  {
      public class ApplicationUser : IdentityUser
      {
          public string DateOfBirth { get; internal set; }
          public string Firstname { get; internal set; }
  
          public string Surname { get; internal set; }
  
          public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
          {
              // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
              var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
              // Add custom user claims here
              return userIdentity;
          }
  
          public Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(ApplicationUserManager manager)
          {
              return Task.FromResult(GenerateUserIdentity(manager));
          }
      }
  
      public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
          public ApplicationDbContext()
              : base("DefaultConnection", throwIfV1Schema: false)
          {
          }
  
          public static ApplicationDbContext Create()
          {
              return new ApplicationDbContext();
          }
      }
  }
  </code></pre>
  
  <p>The line causing the error is this:</p>
  
  <pre><code>    public ApplicationDbContext()
          : base("DefaultConnection", throwIfV1Schema: false)
  </code></pre>
  
  <p>here is the error i have been receiving:</p>
  
  <pre><code>An exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll but was not handled in user code
  
  Additional information: Could not load file or assembly 'MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  </code></pre>
  
  <p>I have a hunch that my <code>web.config</code> has something to do with it but i'm not sure, here is my web.config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;clear/&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-ComputingProjectwh-20170404101246.mdf;Initial Catalog=aspnet-ComputingProjectwh-20170404101246;Integrated Security=True" providerName="System.Data.SqlClient" /&gt;
      &lt;remove name="LocalMySqlServer" /&gt;
      &lt;add name="LocalMySqlServer" connectionString="" providerName="MySql.Data.MySqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;authentication mode="None" /&gt;
      &lt;compilation debug="true" targetFramework="4.6.1" /&gt;
      &lt;httpRuntime targetFramework="4.6.1" /&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Optimization" /&gt;
          &lt;add namespace="Microsoft.AspNet.Identity" /&gt;
        &lt;/namespaces&gt;
        &lt;controls&gt;
          &lt;add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /&gt;
        &lt;/controls&gt;
      &lt;/pages&gt;
      &lt;membership defaultProvider="MySQLMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;remove name="MySQLMembershipProvider" /&gt;
          &lt;add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;profile defaultProvider="MySQLProfileProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
      &lt;roleManager defaultProvider="MySQLRoleProvider"&gt;
  
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;remove name="MySQLRoleProvider" /&gt;
          &lt;add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;sessionState mode="InProc" customProvider="DefaultSessionProvider"&gt;
        &lt;providers&gt;
          &lt;add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /&gt;
        &lt;/providers&gt;
      &lt;/sessionState&gt;
      &lt;siteMap defaultProvider="MySqlSiteMapProvider"&gt;
        &lt;providers&gt;
          &lt;remove name="MySqlSiteMapProvider" /&gt;
          &lt;add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/siteMap&gt;
      &lt;webParts&gt;
        &lt;personalization defaultProvider="MySQLPersonalizationProvider"&gt;
          &lt;providers&gt;
            &lt;remove name="MySQLPersonalizationProvider" /&gt;
            &lt;add name="MySQLPersonalizationProvider" type="MySql.Web.Personalization.MySqlPersonalizationProvider, MySql.Web, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" /&gt;
          &lt;/providers&gt;
        &lt;/personalization&gt;
      &lt;/webParts&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"&gt;
        &lt;remove name="FormsAuthentication" /&gt;
      &lt;/modules&gt;
      &lt;defaultDocument&gt;
        &lt;files&gt;
          &lt;add value="Home.aspx" /&gt;
        &lt;/files&gt;
      &lt;/defaultDocument&gt;
      &lt;directoryBrowse enabled="true" /&gt;
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-6.8.3.0" newVersion="6.8.3.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="mssqllocaldb" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
        &lt;provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"&gt;&lt;/provider&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
    &lt;system.codedom&gt;
  
      &lt;compilers&gt;
        &lt;compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /&gt;
        &lt;compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&amp;quot;Web\&amp;quot; /optionInfer+" /&gt;
      &lt;/compilers&gt;
    &lt;/system.codedom&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;remove invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" /&gt;
        &lt;add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I will continue to try to fix this and will post an answer if i can work it out, thanks for looking.</p>