title: Merge MyDbContext with IdentityDbContext
body: <p>I have a MyDbContext in a separated Data Accass Layer class library project. And I have an ASP.NET MVC 5 project with a default IdentityDbContext. The two context use the same database, and I want to use AspNetUsers table to foreign key for some my tables.
  So I would like to merge the two Context, and I want to use ASP.NET Identity too.</p>
  
  <p>How can I do this?</p>
  
  <p>Please advice,</p>
  
  <p>This is my Context after merge:</p>
  
  <pre><code>public class CrmContext : IdentityDbContext&lt;CrmContext.ApplicationUser&gt; //DbContext
  {
      public class ApplicationUser : IdentityUser
      {
          public Int16 Area { get; set; }
          public bool Holiday { get; set; }
          public bool CanBePublic { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
      }
  
      public CrmContext()
          : base("DefaultConnection")
      {
  
      }
  
      public DbSet&lt;Case&gt; Case { get; set; }
      public DbSet&lt;CaseLog&gt; CaseLog { get; set; }
      public DbSet&lt;Comment&gt; Comment { get; set; }
      public DbSet&lt;Parameter&gt; Parameter { get; set; }
      public DbSet&lt;Sign&gt; Sign { get; set; }
      public DbSet&lt;Template&gt; Template { get; set; }
      public DbSet&lt;Read&gt; Read { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
      }
  }
  </code></pre>
  
  <p>Here is my RepositoryBase class:</p>
  
  <pre><code>    public class RepositoryBase&lt;TContext, TEntity&gt; : IRepositoryBaseAsync&lt;TEntity&gt;, IDisposable
          where TContext : IdentityDbContext&lt;CrmContext.ApplicationUser&gt; //DbContext
          where TEntity : class
      {
          private readonly TContext _context;
          private readonly IObjectSet&lt;TEntity&gt; _objectSet;
  
          protected TContext Context
          {
              get { return _context; }
          }
  
          public RepositoryBase(TContext context)
          {
              if (context != null)
              {
                  _context = context;
                  //Here it is the error:
                  _objectSet = (_context as IObjectContextAdapter).ObjectContext.CreateObjectSet&lt;TEntity&gt;();
               }
               else
               {
                   throw new NullReferenceException("Context cannot be null");
               }
           }
       }
  </code></pre>
  
  <p>An exception of type <code>'System.Data.Entity.ModelConfiguration.ModelValidationException'</code> occurred in EntityFramework.dll but was not handled in user code</p>
  
  <p><strong>Additional information</strong>: One or more validation errors were detected during model generation:</p>
  
  <p><strong>Update: I found the solution.</strong></p>
  
  <p>I had to remove this naming convention:</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
  }
  </code></pre>
  
  <p>And migrate the ef cf model to db, to rename my tables with the nameing conventions of asp.net identity.
  It is working now!</p>