title: Unable to insert records in SQLite database using Entity Framework 5
body: <p>I was trying to use SQLite database using ADO.NET Entity Framework 5 and I was able to connect to the SQLite database and was able to query records from a table in database. But When I am trying to insert a record into table the <strong>SaveChanges</strong> throws an exception</p>
  <pre><code>&quot;An error occurred while updating the entries. See the inner exception for details.&quot;
  </code></pre>
  <p>Code looks like this:</p>
  <pre><code>var connectionStr = string.Format(&quot;data source={0};Version=3;UseUTF16Encoding=True;&quot;,
      fileName);
  var conn = new SQLiteConnection(connectionStr);
  
  this.personDataContext = new PersonDataContext(conn);
  
  var persons = (from person in File.ReadAllLines(fileName)
                 let p = person.Split(new[] { ',', ' ' },
                                      StringSplitOptions.RemoveEmptyEntries)
                 select new Person
                 {
                     ID = Convert.ToInt32(p[0]),
                     Name = p[1],
                     Address = p[2],
                     MobNo = Convert.ToInt32(p[3]),
                     PhNo = Convert.ToInt32(p[4]),
                     Designation = p[5]
                 }).ToList();
  
  if (this.personDataContext != null &amp;&amp; this.personDataContext.Persons != null)
  {
      foreach (var person in persons)
      {
        this.personDataContext.Persons.Add(person);
      }
  
      var saveFailed = false;
  
      do
      {
          try
          {
              this.personDataContext.SaveChanges();
          }
          catch (DbUpdateConcurrencyException ex)
          {
              saveFailed = true;
              ex.Entries.Single().Reload();
          }
      }
      while (saveFailed);
  }
  </code></pre>
  <p>and when I check the inner exception, then it says that primary key is not defined. So, after defining the primary key into the table, same exception comes every time.</p>
  <p>I am attaching the sample application <a href="https://skydrive.live.com/redir?resid=BF69AAF5344E2B32!318" rel="nofollow noreferrer">here</a>. Use Open Db to open the sample database first and then try to import the CSV file.</p>
  <p>I am using the Code First approach in which I have designed a Model class and connected it with the table in the SQLite database.</p>
  <p>Please help in fixing the problem. Thanks!</p>