部署 asp.net 个启用了自动迁移的应用程序
Deploying asp.net app with automatic migrations enabbled
我在我的 asp.net 4.6 mvc 5 网络应用程序中启用了自动迁移。我向 IdentityUser 模型添加了一个自定义字段,当我 运行 网络应用程序时,我得到
The model backing the 'ApplicationDbContext' context has changed since
the database was created. Consider using Code First Migrations to
update the database
我想我必须 运行 从程序包管理器控制台更新数据库,并在我的开发环境中本地解决它。现在,当我将应用程序部署到上游环境(例如 Azure)时,我该如何触发更新该数据库?
尝试将以下代码添加到 Global.asax
Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Configuration>());
我在我的 asp.net 4.6 mvc 5 网络应用程序中启用了自动迁移。我向 IdentityUser 模型添加了一个自定义字段,当我 运行 网络应用程序时,我得到
The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database
我想我必须 运行 从程序包管理器控制台更新数据库,并在我的开发环境中本地解决它。现在,当我将应用程序部署到上游环境(例如 Azure)时,我该如何触发更新该数据库?
尝试将以下代码添加到 Global.asax
Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Configuration>());