title: Hangfire dependency injection lifetime scope
body: <p>I'm rewriting this entire question because I realize the cause, but still need a solution:</p>
  
  <p>I have a recurring job in Hangfire that runs every minute and check the database, possibly updates some stuff, then exits.</p>
  
  <p>I inject my dbcontext into the class containing the job method. I register this dbcontext to get injected using the following</p>
  
  <pre><code>builder.RegisterType&lt;ApplicationDbContext&gt;().As&lt;ApplicationDbContext&gt;().InstancePerLifetimeScope();
  </code></pre>
  
  <p>However, it seems that Hangfire does not create a seperate lifetime scope every time the job runs, because the constructor only gets called once, although the job method get's called every minute.</p>
  
  <p>This causes issues for me. If the user updates some values in the database (dbcontext gets injected somewhere else, and used to update values), the context still being used Hangfire starts returning out-dated values that have already been changed.</p>