gpt4 book ai didi

entity-framework - Azure 源代码控制部署未运行我最新的 Code First 迁移

转载 作者:行者123 更新时间:2023-12-03 03:17:03 25 4
gpt4 key购买 nike

我有一个使用源代码管理部署部署的 Azure 网站,并使用 EF Code First 迁移来管理我的数据库架构。一切都已设置完毕,似乎运行正常,并且部署没有错误,但数据库中的迁移表中只有 4 个迁移,而应该有 5 个。当我尝试访问数据库时,我的应用程序也会引发以下错误

The model backing the 'dbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

表明并非所有迁移都已运行。我可以在 Azure 上的某个地方查看有关部署的更详细的日志文件,有谁知道为什么迁移会在本地运行而不是在 azure 上运行?

最佳答案

将其添加到您的 dbcontext 构造函数中:

Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Data.Migrations.Configuration>());

注意:将“Context”更改为您的上下文的名称。

关于entity-framework - Azure 源代码控制部署未运行我最新的 Code First 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23394129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com