Andrey
Andrey

Reputation: 21295

Deploying asp.net app with automatic migrations enabbled

I have automatic migration enabled in my asp.net 4.6 mvc 5 web app. I added a custom field to IdentityUser model and when I run the web app I get

The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database

I figured that I have to ran Update-Database from Package Manager Console and that resolved it locally in my dev environment. Now, when I deploy the app to an upstream environment (e.g. Azure) how do I trigger updating that database?

Upvotes: 0

Views: 93

Answers (1)

Amanvir Mundra
Amanvir Mundra

Reputation: 440

Try adding the below code to the Global.asax

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

Upvotes: 1

Related Questions