title: Where to register the context with dependency injection
body: <p>According to <a href="https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db" rel="nofollow noreferrer">this</a> tutorial I should:</p>
  
  <p><code>Register your context with dependency injection</code></p>
  
  <p>The Tutorial describes that I should locate the method
  <code>ConfigureServices()</code> and put in there the code advised.</p>
  
  <p>Here's my <a href="https://github.com/trailmax/OwinADAuthentication/blob/master/ActiveDirectoryAuthentication/App_Start/Startup.cs" rel="nofollow noreferrer">startup.cs</a>:</p>
  
  <pre><code>using Microsoft.Owin;
  using Owin;
  
  [assembly: OwinStartupAttribute(typeof(MyProject.Startup))]
  namespace MyProject
  {
      public partial class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              ConfigureAuth(app);
          }
      }
  }
  </code></pre>
  
  <p>so I don't know where to correctly put the code.</p>
  
  <p>Because the project isn't compatible with .net core 2.1, it was needed to change Project->Property to .Net Framework 4.6.1
  and install packages <code>Microsoft.EntityFrameworkCore.SqlServer</code> and <code>Microsoft.EntityFrameworkCore.Tools</code></p>
  
  <p>I tried to add the dependency injection to <a href="https://github.com/trailmax/OwinADAuthentication/blob/master/ActiveDirectoryAuthentication/Global.asax.cs" rel="nofollow noreferrer">global.asax.cs</a> file as follows:</p>
  
  <pre><code>protected void Application_Start()
          {
              var services = new ServiceCollection();
              ConfigureServices(services);
              AreaRegistration.RegisterAllAreas();
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  
  private void ConfigureServices(IServiceCollection services)
      {
          var connection = @"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0";
          services.AddDbContext&lt;BloggingContext&gt;(options =&gt; options.UseSqlServer(connection));
      }
  </code></pre>
  
  <p>I succeeded with the step and created the controller and it works, but I haven't chosen the right context (BloggingContext), so it created second database. So, I need to create a controller with BloggingContext, do you know how?</p>