Sunday, September 6, 2020

Keep update the entities if the db modified in entity framework

 public class MyContext : DbContext 

{

    public MyContext() {

        Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyContext>());
    }
}

If we declare in global.asax then automatically will done.
 Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyContext>());

No comments: