title: Replacing automatically created ApplicationDbContext
body: <p>I should preface this with a disclaimer saying I'm new to ASP.NET development and don't really understand database contexts, despite spending the last hour reading documentation. When I built my ASP.NET MVC 5 application I chose to have individual user account authentication. Visual Studio created a file called <code>IdentityModels.cs</code>, and within there it defined an <code>ApplicationUser</code> class and a <code>ApplicationDbContext</code> class.</p>
  
  <p>I've done some development work, and my CRUD controllers use <code>ApplicationDbContext</code> to talk to the database, by having this private property on every controller:</p>
  
  <pre><code>private ApplicationDbContext db = new ApplicationDbContext();
  </code></pre>
  
  <p>In the controller actions I then do things like:</p>
  
  <pre><code>return View(db.Trains.ToList());
  </code></pre>
  
  <p>I want to tidy this database context stuff up, but I need to understand it first. My main questions are:</p>
  
  <ol>
  <li>Is it okay to use just one database context for my entire application, like I'm doing now?</li>
  <li>Can I replace the <code>ApplicationDbContext</code> class defined in <code>IdentityModels.cs</code> with my own?</li>
  <li>The <code>ApplicationDbContext</code> class derives from <code>IdentityDbContext&lt;ApplicationUser&gt;</code>, does that mean I should have seperate database contexts for my user authentication stuff provided by Visual Studio, and my own code?</li>
  </ol>
  
  <p>I think my end goal is to use my own database context, called <code>DatabaseContext</code>, which is then used in a base controller that all of my controllers inherit from. Then I only have one place where the database context is instantiated, instead of within every controller.</p>
  
  <p>Who knows, I may be thinking the wrong way about this. Everybody seems to have their own preferred way of dealing with this.</p>
  
  <p>Thank you!</p>