title: Entity framework core insert without changetracking
body: <p>I have a big codebase and unfortunatly I cannot reproduce it with a small code example, but i sort of do this:</p>
  
  <pre><code>    db.Persons.Add(new Person() {Name = "Foo"});
      await db.SaveChangesAsync()
      await db.Persons.FromSql("truncate table Persons;select top 0 * from Persons").ToListAsync();
      db.Persons.Add(new Person() {Name = "Bar"});
      await db.SaveChangesAsync()
  </code></pre>
  
  <p>And end up with this error on last savechanges:</p>
  
  <p><strong>System.InvalidOperationException: The instance of entity type 'InstructionLineAllocationDto' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.</strong> </p>
  
  <p>I am aware that the truncate is a little non-standard. The Id field that is in the error is an Identity field in database I don't really care about.</p>
  
  <p>I can't find any places explaining how to implement staging tables where you truncate often and insert a bunch and this code also wouldn't be a problem if it ran once per tuncate. (But this is a listener that always is active)</p>
  
  <p>So all answers that runs permenently and insert a lot and truncate sometimes, but always is active is interesting.</p>
  
  <p>But my most specific question is how I do this without any kind of change tracking</p>
  
  <p>Code is EntityFrameworkCore SqlServer 2.0.0</p>