title: IIS Web Application with database connection
body: <p>I am working on a web application that is using Entity Framework, the <code>SaveChanges</code> method has been overriden to allow log entries of changes made to the database.</p>
  
  <p>Now on <a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.aspx" rel="nofollow">MSDN</a> it states that the database context is not thread safe. So I have 2 questions.</p>
  
  <p>1) If I want to create the log entries in a thread do I have to use a new DB Context for each thread?</p>
  
  <pre><code>using (var repository = new LoggingRepository(new LoggingDbContext()))
  {
      ((ILoggingRepository)repository).Persist(auditEntries);
  }
  </code></pre>
  
  <p><strong>Update:</strong> The logging database is a separate database from the one where the <code>SaveChanges</code> is overriden</p>
  
  <p>2) Does the application create a new DB Context for each user that connects to the application through IIS?</p>