title: Inherit base Dbcontext class
body: <p>I have a question about <strong>inheriting</strong> a custom <code>DbContext</code> class.</p>
  
  <p>I have created a custom <code>DbContext</code> class called <code>BaseContext</code> in namespace 1 using C# Ado.net entity model generator as shown here:</p>
  
  <pre><code>namespace NS1
  {
     public partial class BaseContext: DbContext
     {
          public BaseContext(): base("name=BaseContext")            
          {
          }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              throw new UnintentionalCodeFirstException();
          }
  
          public virtual DbSet&lt;PLAYERS&gt; PLAYERS { get; set; }   
     }
  }
  </code></pre>
  
  <p>And in the other namespace, I have created another context which uses the same database but its some other tables.</p>
  
  <pre><code>namespace NS2
  {
     public partial class ExtensionContext: DbContext
     { 
         public ExtensionContext(): base("name=ExtensionContext")
         {
         }
  
         protected override void OnModelCreating(DbModelBuilder modelBuilder)
         { 
           throw new UnintentionalCodeFirstException();
         }
  
         public virtual DbSet&lt;CRICKET_PLAYERS&gt; CRICKET_PLAYERS { get; set; }      
     }
  }
  </code></pre>
  
  <p>Now I am in a situation to use <code>PLAYERS</code> DbSet in the <code>ExtensionContext</code>. I have tried to inherit the <code>BaseContext</code> from <code>ExtensionContext</code> and pass the <code>ExtensionContext</code> connection string to the <code>BaseContext</code> constructor which in turn sends to the <code>DbContext</code>.</p>
  
  <p>But during implementation I get an exception stating </p>
  
  <blockquote>
    <p>The PLAYERS name does not exist in the current ExtensionContext</p>
  </blockquote>
  
  <p>Please give me some insight into the possibility of reusing the existing <code>DbSet</code> types in the extended context.</p>
  
  <p>Thanks in advance</p>