title: How do I target another database with Audit.Net - Audit.EntityFramework.Core
body: <p>I'm trying to implement the <code>Audit.EntityFramework.Core</code> package from the <a href="https://github.com/thepirat000/Audit.NET/tree/master/src/Audit.EntityFramework" rel="nofollow noreferrer">Audit.Net repository</a> but am running into some difficulty. I'm unable to save changes or target a different database. I've modified my <code>SaveChanges</code> and <code>SaveChangesAsync</code> function to call the <code>Audit.Net</code> <code>DbContextHelper</code> class's save functions but I'm missing something.</p>
  
  <p>Is there a way to do the following?</p>
  
  <ol>
  <li>Target another database for storing audit data using an audit <code>DbContext</code> that inherits from the <code>DbContext</code> I'm trying to audit?
  
  <pre><code>public class MyDbContext : DbContext {} //Types defined here
  public class AuditDbContext : MyDbContext {} //This context stores audit data into a different DB
  </code></pre></li>
  <li>Not require mapping between the type and its audited type when setting up a global connection? (I'm trying to avoid calling <code>AuditTypeMapper</code> explicitly for each type with a model that's currently undergoing a lot of change).
  
  <pre><code>//MyDbContext has different connection string than AuditDbContext
  Audit.Core.Configuration.Setup()
  .UseEntityFramework(x =&gt; x
      .UseDbContext&lt;AuditDbContext&gt;());
  </code></pre></li>
  </ol>
  
  <p>I've tried code that resembles the following but get runtime errors on <code>SaveChanges</code> that indicate that there is no model set up. Adding a migration for the <code>AuditDbContext</code> didn't help. </p>