title: How to use InsertOrReplace in sqlite.net PCL?
body: <p>I am using the PCL version of sqlite.net from here (<a href="https://github.com/oysteinkrog/SQLite.Net-PCL" rel="noreferrer">https://github.com/oysteinkrog/SQLite.Net-PCL</a>).</p>
  
  <p>Here is my simple class.</p>
  
  <pre><code>    public class LogEntry
      {
        [PrimaryKey, AutoIncrement]
        public int Key { get; set;}
        public DateTime Date { get; set; }
      }
  </code></pre>
  
  <p>When a new instance of LogEntry is created, the Key is automatically set to 0.  I set the Date to something and then call InsertOrReplace.  The record does get saved in my database.  The Key field gets the autoincrement value which happens to be 0 since it is the first record.</p>
  
  <p>I then create a new instance of LogEntry (Key is automatically initialized to 0) and set the date to something else.  I then call InsertOrReplace.  Since there is an existing record with a Key of 0 that record gets updated.</p>
  
  <p>What is the proper way to deal with this?  I considered initializing the Key to -1, but that didn't seem to work either.</p>
  
  <p>Does anyone have an example of this working?</p>