title: Why InsertAll in SQLITE crashes?
body: <p>I am using InsertAll to save an ObservableCollection TickRecords into SQLITE database:</p>
  
  <pre><code>private static readonly ObservableCollection&lt;TickRecord&gt; TickRecords = new ObservableCollection&lt;TickRecord&gt;();
  </code></pre>
  
  <p>TickRecord is define like this:`</p>
  
  <pre><code>public class TickRecord : INotifyPropertyChanged
  {
  //
  // Primary Key
  //
  private long _key;
  [PrimaryKey]
  public long Key
      {
      get
          {
          return _key;
          }
      set
          {
          _key = value;
          OnPropertyChanged( "Key" );
          }
      }
  
  
  //
  // Timestamp
  //
  private DateTime _tickStartDate;
  public DateTime TickStartDate
      {
      get
          {
          return _tickStartDate;
          }
      set
          {
          _tickStartDate = value;
          OnPropertyChanged( "TickStartDate" );
          }
      }
  
  private DateTime _tickEndDate;
  public DateTime TickEndDate
      {
      get
          {
          return _tickEndDate;
          }
      set
          {
          _tickEndDate = value;
          OnPropertyChanged( "TickEndDate" );
          }
      }
  
  
  //
  // Record Duration in Seconds
  //
  private byte _durationInSeconds;
  public byte DurationInSeconds
      {
      get
          {
          return _durationInSeconds;
          }
      set
          {
          _durationInSeconds = value;
          OnPropertyChanged( "DurationInSeconds" );
          }
      }
  </code></pre>
  
  <p>and saving into SQLITE is done like this:</p>
  
  <pre><code>    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.High, () =&gt; Database.Database.AddAllTickRecords( TickRecords ) );
  </code></pre>
  
  <p>and AddAllTickRecords is defined like this:</p>
  
  <pre><code>    public static void AddAllTickRecords( IEnumerable&lt;TickRecord&gt; list )
      {
      using ( var db = new SQLiteConnection( new SQLitePlatformWinRT(), DbPath ) )
          {
          db.InsertAll( list );
          }
      }
  </code></pre>
  
  <p>Any idea why I am getting an error here?</p>
  
  <p>The error I getting from the debugger is:</p>
  
  <pre><code>    **An exception of type 'SQLite.Net.SQLiteException' occurred in SQLite.Net.dll but was not handled in user code
  Additional information: Constraint**
  
  and 
  
      **{SQLite.Net.SQLiteException: Constraint
     at SQLite.Net.PreparedSqlLiteInsertCommand.ExecuteNonQuery(Object[] source)
     at SQLite.Net.SQLiteConnection.Insert(Object obj, String extra, Type objType)
     at SQLite.Net.SQLiteConnection.Insert(Object obj)
     at SQLite.Net.SQLiteConnection.&lt;&gt;c__DisplayClass100_0.&lt;InsertAll&gt;b__0()
     at SQLite.Net.SQLiteConnection.RunInTransaction(Action action)
     at SQLite.Net.SQLiteConnection.InsertAll(IEnumerable objects, Boolean runInTransaction)
     at BTLE.Database.Database.AddAllTickRecords(IEnumerable`1 list)
     at BTLE.MainPage.&lt;&gt;c.&lt;DecodeMessageResponse&gt;b__123_0()}**
  </code></pre>