I'm using a web app asp.net (.net framework) identity framework published on Azure.
I change in web.config
file the connectionString
with Azure string and all works fine.
I Made a simple change in a context and when I send the get
request postMan returns me this error:
The model backing the 'MYCONTEXTNAME' context has changed since the database was created. Consider using Code First Migrations to update the database.
When I was working locally I use the commands: Add-Migrations
+ Update-Database
to update the table structure, but in Azure what I have to do?
如何解决此问题?
谢谢
G。
因此,当数据库架构发生任何更改时,您需要照常生成迁移,然后在Azure数据库上也执行迁移。
Generally when we deploy on any environment, Azure here, we use it using scripts and use some tool for example Jenkins to automate this. And for migrations, you can use migrate.exe for executing migrations using scripts.
否则,您也可以像在本地环境中一样从Visual Studio中执行迁移。但是,不建议将其用于生产实例。只要确保启动项目中的连接字符串指向Azure数据库,并且所需的防火墙设置已配置为允许从执行命令的计算机和Azure上的数据库进行访问。
您还需要运行对Azure数据库的那些迁移更改。
在Azure中备份数据库并在代码中更改连接字符串并运行迁移更改
转到程序包管理器控制台,然后
获取脚本并将其应用于您的Azure数据库