title: EF6 CodeFirst Ubercontext DB Creation with use of multipe DBContext
body: <p>I have an issue with Entity Framework 6. I try to create my huge DB (CodeFirst) (50+ tables) with a single "ubercontext" and then work with different dbcontext for different concerns.</p>
  
  <p>This UberContext contains:</p>
  
  <pre><code>    public class UberDbContext :DBContent
      {
          Database.SetInitializer&lt;UberDbContext &gt;((new DropCreateDatabaseIfModelChanges&lt;UberDbContext&gt;()));
              public UberDbContext()
                  : base("name=myDb")
              {
                  this.Configuration.LazyLoadingEnabled = false;
                  this.Configuration.ProxyCreationEnabled = false;
                  this.Configuration.AutoDetectChangesEnabled = false;
                  this.Configuration.ValidateOnSaveEnabled = false;
              }
      public DbSet&lt;MyEntity1&gt; MyEntity1 { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
              {
                  modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
                  const string schemaName = "mySchema";
      ...//all my different entities
                  modelBuilder.Entity&lt;MyEntity1&gt;().ToTable("MyEntity1", schemaName);
      ...//all my other tables
                  modelBuilder.Configurations.Add(new MyEntity1Map());
      ...//all my other entitymaps
      }
  </code></pre>
  
  <p>This works fine, the DB is created when I first use this UberContext. All the Keys and constrains are created with the FluentApi. 
  I just have to push it with an        <code>UberContext.MyEntity1.Add(myDummyEntity1)</code>
  But if I use my other Context which just needs a part of the Db, the code throws a </p>
  
  <blockquote>
    <p>ModelValidationException 'MyEntity1' has no key defined. Define the
    key for this EntityType.</p>
  </blockquote>
  
  <p>But this should be configurated via the fluentapi. If I add the Key Attribute this works fine but then the constrains cannot be resolved.
  It seems that the configuration is ignored.</p>
  
  <p>I searched for this problem the last two days and found nothing.
  The idea with the ubercontext comes from Julie Lerman according to her book "DBContext" and this article:
  <a href="http://msdn.microsoft.com/en-us/magazine/jj883952.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/jj883952.aspx</a></p>
  
  <p>My other Context looks like this:</p>
  
  <pre><code>public partial class MyEntity1DbContext:BaseContext&lt;MyEntity1DbContext&gt;
  {
  public DbSet&lt;MyEntity1&gt; MyEntity1 {get;set;} 
  //...
  }
  </code></pre>
  
  <p>and BaseContext:</p>
  
  <pre><code>public class BaseContext&lt;TContext&gt; : DbContext
      where TContext : DbContext
  {
      static BaseContext()
      {
          Database.SetInitializer&lt;TContext&gt;(null);
      }
  
      protected BaseContext()
          : base("name=myDb")
      {
  
      }
  }
  </code></pre>
  
  <p>I don't know what to do anymore. I can't change the DB and I don't want all the tables in just 1 DbContext. I think it should be possible or else Julie wouldn't write about it. And it should not be that difficult.
  Help would be appreciated. 
  Cheers
  Oliver</p>