title: Dependency injection in ASP.NET Core 2 throws exception
body: <p>I receive following exception when I try to use custom DbContext in <code>Configure</code> method in <code>Startup.cs</code> file. I use ASP.NET Core in version 2.0.0-preview1-005977</p>
  
  <blockquote>
    <p>Unhandled Exception: System.Exception: Could not resolve a service of type 'Communicator.Backend.Data.CommunicatorContext' for the parameter 'dbContext' of method 'Configure' on type 'Communicator.Backend.Startup'. ---> System.InvalidOperationException: Cannot resolve scoped service 'Communicator.Backend.Data.CommunicatorContext' from root provider.</p>
  </blockquote>
  
  <p>This exception is also thrown in case when I try to receive other instance.</p>
  
  <blockquote>
    <p>Unhandled Exception: System.Exception: Could not resolve a service of type 'Communicator.Backend.Services.ILdapService'  <code>...</code></p>
  </blockquote>
  
  <p>Here are my <code>ConfigureServices</code> and <code>Configure</code> methods.</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddDbContext&lt;CommunicatorContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
      services.AddCookieAuthentication();
      services.Configure&lt;LdapConfig&gt;(Configuration.GetSection("Ldap"));
      services.AddScoped&lt;ILdapService, LdapService&gt;();
      services.AddMvc();
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CommunicatorContext dbContext, ILdapService ldapService)
  {
      app.UseAuthentication();
      app.UseWebSockets();
      app.Use(async (context, next) =&gt;
      {
          if (context.Request.Path == "/ws")
          {
              if (context.WebSockets.IsWebSocketRequest)
              {
                  WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync();
                  await Echo(context, webSocket);
              }
              else
              {
                  context.Response.StatusCode = 400;
              }
          }
          else
          {
              await next();
          }
      });
      app.UseMvc();
      DbInitializer.Initialize(dbContext, ldapService);
  }
  </code></pre>