1

I am currently using auto-migrations with the following powershell console commands: add-migration update-database

I would like to know if there is an option to update the database automatically if the model changes (DbContext) without using the console commands.

Thanks.

1 Answer 1

1

I use

public class DataContext : DbContext
{

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {

        Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataContext,Configuration>());

        base.OnModelCreating(modelBuilder);
    }
}

This causes the database migrations to the latest version when the data context is created at code runtime.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.