实体框架代码优先迁移保留现有数据 [英] entity framework code first migration keep existing data

查看:98
本文介绍了实体框架代码优先迁移保留现有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是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.

这篇关于实体框架代码优先迁移保留现有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆