title: EF 6 - Invalid column name 'Discriminator', two DbContexts
body: <p>I have an MVC 5 app. I would like to use the standard aspnet.identity provider to enable user login through the standard \Account views. However, I also need to connect to a third-party database and want to use EF code-first for this too.</p>
  
  <p>The context for my main database I took from a Scott Allen Pluralsight. I don't know why or what the "ApplicationUser" class is doing inheriting from the IdentityUser but it worked in his video and with a previous website I created. It looks as follows:</p>
  
  <pre><code>namespace ESBAMPortal.DataLayer
  {
      // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
      public class ApplicationUser : IdentityUser
      {
      }
  
      class PortalContext : IdentityDbContext&lt;ApplicationUser&gt;, ESBAMPortal.DataLayer.IPortalContext
      {
          public PortalContext()
              : base("ESBamPortalConString")
          {
              this.Configuration.LazyLoadingEnabled = false;
          }
  
          public virtual DbSet&lt;DomainClasses.Portal&gt; Portal {get; set;}
      }
  }
  </code></pre>
  
  <p>The context for the third-party database is as follows:</p>
  
  <pre><code>namespace ESBAMPortal.DataLayer
  {
  
      public class ESBContext : DbContext, ESBAMPortal.DataLayer.IESBContext
      {
          public ESBContext()
              : base("ESBExceptionConString")
          {
              this.Configuration.LazyLoadingEnabled = false;
          }
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
          }
  
          public virtual DbSet&lt;ActionType&gt; ActionTypes { get; set; }
          public virtual DbSet&lt;Alert&gt; Alerts { get; set; }
          public virtual DbSet&lt;AlertCondition&gt; AlertConditions { get; set; }
          public virtual DbSet&lt;AlertEmail&gt; AlertEmails { get; set; }
          public virtual DbSet&lt;AlertHistory&gt; AlertHistories { get; set; }
          public virtual DbSet&lt;AlertSubscription&gt; AlertSubscriptions { get; set; }
          public virtual DbSet&lt;AlertSubscriptionHistory&gt; AlertSubscriptionHistories { get; set; }
          public virtual DbSet&lt;AuditLog&gt; AuditLogs { get; set; }
          public virtual DbSet&lt;AuditLogMessageData&gt; AuditLogMessageDatas { get; set; }
          public virtual DbSet&lt;Batch&gt; Batches { get; set; }
          public virtual DbSet&lt;Configuration&gt; Configurations { get; set; }
          public virtual DbSet&lt;ContextProperty&gt; ContextProperties { get; set; }
          public virtual DbSet&lt;Fault&gt; Faults { get; set; }
          public virtual DbSet&lt;Message&gt; Messages { get; set; }
          public virtual DbSet&lt;MessageData&gt; MessageDatas { get; set; }
          public virtual DbSet&lt;ProcessedFault&gt; ProcessedFaults { get; set; }
          public virtual DbSet&lt;UserSetting&gt; UserSettings { get; set; }
      }
  }
  </code></pre>
  
  <p>When I run the website I am able to pull data from the third-party website ok. However, when I try to login I receive the message:</p>
  
  <pre><code>Invalid column name 'Discriminator'
  </code></pre>
  
  <p>This is thrown as a result of making the call:</p>
  
  <pre><code>var user = await UserManager.FindAsync(model.UserName, model.Password);
  </code></pre>
  
  <p>Running EF Profiler I can see that it's attempting to execute the following SQL:</p>
  
  <pre><code>SELECT [Limit1].[C1]            AS [C1],
         [Limit1].[Id]            AS [Id],
         [Limit1].[UserName]      AS [UserName],
         [Limit1].[PasswordHash]  AS [PasswordHash],
         [Limit1].[SecurityStamp] AS [SecurityStamp]
  FROM   (SELECT TOP (1) [Extent1].[Id]            AS [Id],
                         [Extent1].[UserName]      AS [UserName],
                         [Extent1].[PasswordHash]  AS [PasswordHash],
                         [Extent1].[SecurityStamp] AS [SecurityStamp],
                         '0X0X'                    AS [C1]
          FROM   [dbo].[AspNetUsers] AS [Extent1]
          WHERE  ([Extent1].[Discriminator] = N'ApplicationUser')
                 AND ((((UPPER([Extent1].[UserName])) = (UPPER('rob' /* @p__linq__0 */)))
                       AND (NOT ((UPPER([Extent1].[UserName]) IS NULL)
                                  OR (UPPER('rob' /* @p__linq__0 */) IS NULL))))
                       OR ((UPPER([Extent1].[UserName]) IS NULL)
                           AND (UPPER('rob' /* @p__linq__0 */) IS NULL)))) AS [Limit1]
  </code></pre>
  
  <p>Problem is, the AspNetUsersTable has no discriminator column.</p>
  
  <p>Could anyone please explain where I've gone wrong and how I should fix?</p>