model change issue

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
m.ende
Posts: 4
Joined: Tue 26 Aug 2014 07:05

model change issue

Post by m.ende » Wed 03 Sep 2014 10:18

Hi,

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 AutomaticMigration is turned off. (as described on http://blog.devart.com/entity-framework ... force.html)

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");
My Model-context:

Code: Select all

    public class MyModel : DbContext
    {
        public MyModel()
            : base()
        {
            System.Data.Entity.Database.SetInitializer<ASproModel>(new DbContextCreateDatabaseIfNotExists());
        }
        //...some other stuff...
The DbContextCreateDatabaseIfNotExists:

Code: Select all

        public class DbContextCreateDatabaseIfNotExists : CreateDatabaseIfNotExists<ASproModel>
        {
            protected override void Seed(ASproModel context)
            {
                ContextSeeder.Seed(context);
            }
        }

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: model change issue

Post by Shalex » Thu 04 Sep 2014 16:53

m.ende wrote:Is it possible to use the automatic migration with sqlite?
Yes, it is possible. The way how to enable migrations is described at http://blogs.msdn.com/b/adonet/archive/ ... rough.aspx > Enabling Migrations. Automatic migrations will work until any unsupported operation is encoutered: http://blog.devart.com/entity-framework ... ionSupport. We recommend using the AutomaticMigrationsEnabled=false mode to be able to check (and replace with a workaround) generated migration operations before applying them.

Post Reply