Sqlite error 1: ‘no such table: __efmigrationshistory’.

SQLite Error 1: ‘No such table: __efmigrationshistory’

When you encounter this error in SQLite, it means that the table ‘__efmigrationshistory’ does not exist in your database.

This table is typically used by Entity Framework Migrations to keep track of database schema changes. It is created automatically when you use migrations to apply changes to your database.

Here’s an example of how you can create this table using Entity Framework Migrations:


    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "__efmigrationshistory",
                c => new
                    {
                        MigrationId = c.String(nullable: false, maxLength: 150),
                        ProductVersion = c.String(nullable: false, maxLength: 32),
                    })
                .PrimaryKey(t => t.MigrationId);
        }
        
        public override void Down()
        {
            DropTable("__efmigrationshistory");
        }
    }
  

In the above example, the CreateTable method is used to create the ‘__efmigrationshistory’ table with two columns: ‘MigrationId’ and ‘ProductVersion’.

After creating this migration, you can apply it to your database using the ‘Update-Database’ command in the Package Manager Console. This will create the ‘__efmigrationshistory’ table in your database and track future migrations.

Read more

Leave a comment