I've done some steps forward but now I'm hanging around with this issue:
Code: Select all
Exception:Caught: "The model backing the 'MyModel' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)." (System.InvalidOperationException)
A System.InvalidOperationException was caught: "The model backing the 'MyModel' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)."
Time: 03.09.2014 12:02:32
Thread:Worker Thread[15160]The database is created without any issues, when I start the application, and it's also correctly seeded. So I would expect that everything works fine. But when I start to add entities it produces this stacktrace above.
Can you help me?
Thanks
Marc
Btw.: Is it possible to use the automatic migration with sqlite? If so, do you have an example?
My initialization of the database:
Code: Select all
            var monitor = new Devart.Data.SQLite.SQLiteMonitor() {IsActive = true};
            var config = Devart.Data.SQLite.Entity.Configuration.SQLiteEntityProviderConfig.Instance;
            config.Workarounds.IgnoreSchemaName = true;
            
            // removed because not running seed properly
            //DbConfiguration.SetConfiguration(new Devart.Data.SQLite.Entity.SQLiteEntityProviderServicesConfiguration());
            Database.DefaultConnectionFactory = new SQLiteConnectionFactory(".\\", "FailIfMissing=False");
            logger.Info("Start migration");
            
            DbInterception.Add(new NLogCommandInterceptor());
            _model = new MyModel();
            _model.Database.Initialize(false);
            
            logger.Info("Finish migration");
Code: Select all
    public class MyModel : DbContext
    {
        public MyModel()
            : base()
        {
            System.Data.Entity.Database.SetInitializer<ASproModel>(new DbContextCreateDatabaseIfNotExists());
        }
        //...some other stuff...
Code: Select all
        public class DbContextCreateDatabaseIfNotExists : CreateDatabaseIfNotExists<ASproModel>
        {
            protected override void Seed(ASproModel context)
            {
                ContextSeeder.Seed(context);
            }
        }