title: ASP.NET 5 multiple dbcontext problems
body: <p>I'm playing around with the new ASP.NET 5 beta 8 and having trouble when I have two dbcontext. </p>
  
  <p>I have the following project structure. </p>
  
  <pre><code>-Data(Identity 3 db with other entities)
  -Resources (Contains a db with translations)
  -WebApp 
  </code></pre>
  
  <p>Stripped away some code in Startup.cs in WebApp</p>
  
  <pre><code> public void ConfigureServices(IServiceCollection services)
   {
          services.AddEntityFramework()
              .AddSqlServer()
              .AddDbContext&lt;DatabaseContext&gt;(opt =&gt; opt.UseSqlServer(Configuration["Data:MainDb:ConnectionString"]));
  
          services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddEntityFrameworkStores&lt;DatabaseContext&gt;()
              .AddDefaultTokenProviders();
  
          services.AddEntityFramework()
              .AddSqlServer()
              .AddDbContext&lt;ResourceDbContext&gt;(opt =&gt; opt.UseSqlServer(Configuration["Data:Resources:ConnectionString"]));
  
          services.AddTransient&lt;IResourceDbContext, ResourceDbContext&gt;();
          services.AddTransient&lt;IDatabaseContext, DatabaseContext&gt;();
  }
  </code></pre>
  
  <p>In both ResourceDbContext and DatabaseContext I do the following</p>
  
  <pre><code>    public ResourceDbContext(DbContextOptions options) : base(options)
      {
          _connectionString = ((SqlServerOptionsExtension)options.Extensions.First()).ConnectionString;
      }
  
  
      protected override void OnConfiguring(DbContextOptionsBuilder options)
      {
          options.UseSqlServer(_connectionString);
      }
  </code></pre>
  
  <p>However when I read my connectionstrings from appsettings.json I receive the correct values in ConfigureServices. But the DbContextOptions only contains the latest loaded value, in this case the connectionstring for Resources. So both dbcontext establishes a connection to Resource db. </p>
  
  <p>I'm unable to find any information about this.</p>