Entity Framework MigrationSqlGenerator for SQLite

后端 未结 5 753
予麋鹿
予麋鹿 2020-12-19 00:57

is there a MigrationSqlGenerator for SQLite to use with entity framework? I only found one from devart which is commercial.

No MigrationSqlGenerator f

5条回答
  •  误落风尘
    2020-12-19 01:18

    For anyone who is looking for a generator that handles migrations as well I found a nuget package at https://sqliteef6migrations.codeplex.com called "System.Data.SQLite.EF6.Migrations".

    After you have installed the package you will need to make the following changes to the Migrations Configuration Method.

     public Configuration()
     {
        AutomaticMigrationsEnabled = false;
        SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator());
     }
    

    The complete class should look something like this.

    namespace YourNamespace
    {
        using System.Data.Entity.Migrations;
        using System.Data.SQLite.EF6.Migrations;
    
        internal sealed class Configuration : DbMigrationsConfiguration
        {
            public Configuration()
            {
                AutomaticMigrationsEnabled = false;
                SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator());
            }
    
            protected override void Seed(YourContext context)
            {
                //  This method will be called after migrating to the latest version.
            }
        }
    }
    

提交回复
热议问题