c# - handle Entity Framework migration when live and development Database is same
问题描述
I am using entity framework 6 with code first approach. I use the same database for live & development purpose, when I make change in model or add new fields in the model, then add-migration and run update-database, migration add and update successfully locally and when run application from visual studio its works fine. But on the other hand my already published same application crashes, when I open the live URL, I see this error
one solution is to re-publish the application to live but I want a different best solution.
I want to know the best practice of working with entity framework , I can add or modify model using EF while live application working fine as it was working before model modification. I am using SQL Server as Database.
解决方案
我将相同的数据库用于实时和开发目的,
这太糟糕了,甚至都不好笑。这意味着你永远不能做出重大改变。这也意味着开发过程中的任何代码错误都可能破坏生产数据。这就像说“我有健康问题。我在吞毒,为什么不好”不好。
标准做法(甚至不是最好的,它是标准的)是为每个环境拥有单独的数据库副本。许多团队甚至为所有或特定开发人员制作数据库副本——即使数据库有几十 TB 大。
但是用于开发和生产的一个数据库副本永远不会起作用,而且它显然会破坏生产数据库。开始使用副本。
推荐阅读
- python - 遍历 df 行并根据 if 语句执行计算
- python - 类型错误:+ 不支持的操作数类型:添加 numpy 数组时的“生成器”和“生成器”
- sml - SML:定义一个数组
- c - 如何在数组中找到坐标为 (x1, y1) 和 (x2, y2) 的两点之间的直线长度?
- android - 我们可以使用 android ML Kit Image Labeling 来检测产品吗
- fish - 大括号扩展作为标志参数对
- python - telegram stop and block bot telethon
- kotlin - 无法导入 androidx.datastore.dataStore(尝试重新创建 Google Codelab 示例)
- flutter - 如何在不传递所需值的情况下调用接受参数的方法?
- google-colaboratory - 信息:张量流:在模型/faster_rcnn 等待新的检查点