Skip to content

ShiJess/Link.EntityFramework.Sqlite

 
 

Repository files navigation

Link.EntityFramework.Sqlite —— Entity Framework 6 Sqlite

NuGet

Project Description

Migrations for Entity Framework 6 SQLite provider

Limitations:

  • Relationships are not enforced with constraints
  • There can be only one identity column per table and will be created as integer and primary key (other primary keys will be ignored)
  • ...
  • can not change primary key column

Simplest Usage

  • Download the library (using NuGet)
  • Create a migration configuration
  • Setup the migration configuration (usually during first context creation)
internal sealed class ContextMigrationConfiguration : DbMigrationsConfiguration<Context>
{
    public ContextMigrationConfiguration()
    {
        AutomaticMigrationsEnabled = true;
        AutomaticMigrationDataLossAllowed = true;
    }
}

Old Version Example

Not Realy Delete Column,Just Rename Column

class Context : DbContext
{
    static Context()
    {
        Database.SetInitializer(new MigrateDatabaseToLatestVersion<Context, ContextMigrationConfiguration>(true));
    }

    // DbSets
}

New Version Example

class Context : DbContext
{
    static Context()
    {
        Database.SetInitializer(new MigrateDatabaseToLatestVersionExtention<Context, ContextMigrationConfiguration>(true));
    }

    // DbSets
}

Fix

Implementation

  • Drop Column Imp
    • Rename Column
    • Record Delete Column Info
    • Add Additional Migration
      • Create Temp Table Base Record Info
      • Copy Data To Temp Table
      • Drop Original Table
      • Rename Temp Table
  • Alter Column Imp
    • Similar Drop Column
    • Alter Column Will Migrate Data Column By Column

Refrence

About SQLite

  • Boolean need set default 0/1, not True/False - add column
    • System.Data.Sqlite cast error for True/False - GetBoolean

About

Migrations for SQLite Entity Framework provider —— Code First Support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%