Saturday, 19 November 2016

How to disable Migrations in MVC Visual studio.

Some times you add the properties later on in the Model. And after creating the db it doesn't update the db with the new properties added in your class unless you disable the Migrations. Easy way to disable the migration. 

Just go to your DbContext file and paste this.


protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            Database.SetInitializer<UniversityWebContext>(null);
            base.OnModelCreating(modelBuilder);
        }


Just change the name of the project . Here my project name is  "UniversityWebContext".



1 comment:

  1. Thanks for sharing about disable Migrations in MVC Visual studio.
    VB.Net Migration

    ReplyDelete