title: SQL logic error or missing database no such function: last_rows_affected
body: <p>I'm trying to run EF6 Code First with SQLite (version 3.11) in Ubuntu/Mono.</p>
  
  <p><strong>Program.cs</strong>:</p>
  
  <pre><code>    static void Main(string[] args)
      {
          var db = new Context();
          var user = new User() { Nome = "Teste"};
  
          db.User.Add(user);
  
          db.SaveChanges();
  
      }
  </code></pre>
  
  <p><strong>Context.cs:</strong></p>
  
  <pre><code>public class Context : DbContext
  {
      public Context():base("Context")
      {
          Database.SetInitializer&lt;Context&gt;(new CreateDatabaseIfNotExists&lt;Context&gt;());
      }
      public DbSet&lt;User&gt; User { get; set; }
  }
  </code></pre>
  
  <p><strong>User.cs:</strong></p>
  
  <pre><code>[Table("User")]
  public class User
  {
      [Key]
      public int Id { get; set; }
  
      public string Nome { get; set; }
  }
  </code></pre>
  
  <p><strong>Whenever it gets to db.SaveChanges(), it throws the following exception:</strong></p>
  
  <pre><code>System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; System.Data.SQLite.SQLiteException: SQL logic error or missing database
  no such function: last_rows_affected
    at System.Data.SQLite.SQLite3.Prepare (System.Data.SQLite.SQLiteConnection cnn, System.String strSql, System.Data.SQLite.SQLiteStatement previous, System.UInt32 timeoutMS, System.String&amp; strRemain) [0x0051b] in &lt;2502d764dcbe41f1ad84e79b77538a55&gt;:0
    at System.Data.SQLite.SQLiteCommand.BuildNextCommand () [0x0007c] in &lt;2502d764dcbe41f1ad84e79b77538a55&gt;:0
    --- End of inner exception stack trace ---
    at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update () [0x00080] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.&lt;Update&gt;b__2 (System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator ut) [0x00000] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T] (T noChangesResult, System.Func`2[T,TResult] updateFunction) [0x00063] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update () [0x00000] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    at System.Data.Entity.Core.Objects.ObjectContext.&lt;SaveChangesToStore&gt;b__d () [0x00000] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T] (System.Func`1[TResult] func, System.Data.Entity.Infrastructure.IDbExecutionStrategy executionStrategy, System.Boolean startLocalTransaction, System.Boolean releaseConnectionOnSuccess) [0x00064] in &lt;ba0120930fe443a3b992bc3dba4c985a&gt;:0
    --- End of inner exception stack trace ---
  </code></pre>
  
  <p>Does anyone know why this is happening?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I managed to find out what was going on. It looks like that the database created was read-only. All I had to do was change its permissions and it worked!</p>