title: Entity Framework 6 with SQLite 3 Code First - Won't create tables
body: <p>Using latest versions of EF6 and SQLite from NuGet. I finally got the app.config file to work after some useful posts on Stackoverflow. Now the problem is that the tables are not being created although the database is.</p>
  
  <p>My app.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
    &lt;/startup&gt;
    &lt;entityFramework&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SQLite"
                  type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;remove invariant="System.Data.SQLite" /&gt;
        &lt;add name="SQLite Data Provider"
             invariant="System.Data.SQLite"
             description=".Net Framework Data Provider for SQLite"
             type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /&gt;
        &lt;remove invariant="System.Data.SQLite.EF6" /&gt;
        &lt;add name="SQLite Data Provider (Entity Framework 6)"
             invariant="System.Data.SQLite.EF6"
             description=".Net Framework Data Provider for SQLite (Entity Framework 6)"
             type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
    &lt;connectionStrings&gt;
      &lt;add name="MyDBContext"
            connectionString="Data Source=|DataDirectory|MyDB.sqlite"
            providerName="System.Data.SQLite" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My simple test program:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          using (var db = new MyDBContext())
          {
              db.Notes.Add(new Note { Text = "Hello, world" });
              db.Notes.Add(new Note { Text = "A second note" });
              db.Notes.Add(new Note { Text = "F Sharp" });
              db.SaveChanges();
          }
  
          using (var db = new MyDBContext())
          {
              foreach (var note in db.Notes)
              {
                  Console.WriteLine("Note {0} = {1}", note.NoteId, note.Text);
              }
          }
  
          Console.Write("Press any key . . . ");
          Console.ReadKey();
      }
  
      public class Note
      {
          public long NoteId { get; set; }
          public string Text { get; set; }
      }
  
      public class MyDBContext : DbContext
      {
          // default constructor should do this automatically but fails in this case
          public MyDBContext()
              : base("MyDBContext")
          {
  
          }
          public DbSet&lt;Note&gt; Notes { get; set; }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
          }
      }
  }
  </code></pre>
  
  <p>If I create the table manually the program works fine and the table is updated. If I delete the database, EF creates it but doesn't create the table and the program fails when it attempts to read back the data with an error message that the table does not exist.</p>
  
  <p>Has anyone managed to get Code First working with EF6 yet? Would appreciate help/guidance on this as I'm now completely stuck!!!</p>
  
  <p>Thanks all.</p>