title: How to retrieve auto-incremented Id in ServiceStack OrmLite?
body: <p>For a table that has an identity:</p>
  
  <pre><code>    [AutoIncrement]
      public int Id { get; set;}
  </code></pre>
  
  <p>When inserting a new row into the database, what is the best way to retrieve the Id of the object?</p>
  
  <p>For example:</p>
  
  <blockquote>
    <p>db.Insert&lt;> (new User());</p>
  </blockquote>
  
  <p>The value of the Id is 0 after the insert, but in the database this obviously is not the case. The only possibility I can see is the following:</p>
  
  <pre><code>Id = (int)db.GetLastInsertId();
  </code></pre>
  
  <p>However I don't believe this would be a safe call to make. If there are 100's of inserts happening at the same time, an Id for another insert may be returned. In EF when you do an insert the Id is set for you.</p>
  
  <p>Does anyone know the best way to go about this? </p>