实体框架代码优先迁移保留现有数据
我使用的是EF 6.1,我在生产环境中的现有数据库中使用代码优先方法.
I am using EF 6.1 and I use code first approach with an existing database with data in a production environment.
是否完全可以迁移模型更改并保留现有客户的数据?
Is it possible at all to migrate model changes and keep the existing customer`s data?
是的,但是,根据具体情况(更改的复杂性),它可能会很复杂:
Yes, however, it can be complicated depending on specific case (on complexity of changes):
概述: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/existing-database
阅读此内容: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/index
然后执行以下操作: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/teams
更新:根据重定向更新了链接.
Update: updated the links based on redirects.