How to exclude one table from automatic code first migrations in the Entity Framework?

后端 未结 5 1356
我寻月下人不归
我寻月下人不归 2020-12-16 05:32

I\'m using the Entity Framework in the Code First mode with automatic migrations enabled. Now, I have one entity whose table should not be managed (migrated) by the

5条回答
  •  爱一瞬间的悲伤
    2020-12-16 06:05

    My TEMPORARY solution, only for dev environments. I have a separate script that runs migration and program run does not check them. So in unexpected case I was possible to invoke Ignore() and run migrations with this line. When it was completed, I removed this line!

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // comment out this code after migrations are done
            modelBuilder.Ignore();
        }
    

提交回复
热议问题