如何在EntityFramework 4.3中为现有数据库创建迁移? [英] How do I create a migration for an existing database in EntityFramework 4.3?

查看:156
本文介绍了如何在EntityFramework 4.3中为现有数据库创建迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想要开始使用EntityFramework 4.3迁移。我想知道我是否可以将现有数据库转换为启用迁移的数据库,并且EF假定只有从那时起的更改才被视为迁移。

so I want to get started with EntityFramework 4.3 migrations. I wanted to know if I can convert an existing database to a migration-enabled database and have EF assume that only changes from then on should be considered migrations.

推荐答案

这里介绍一个很好的步骤: http://thedatafarm.com/data-access/using-ef-4- 3-code-first-migrations-with-a-existing-database /

A nice walk-through for this is posted here: http://thedatafarm.com/data-access/using-ef-4-3-code-first-migrations-with-an-existing-database/

我建议的一个改变是简单地注释掉Up和Down方法,直到部署迁移。之后,您可以取消注释代码,如果需要,您可以创建一个新的数据库。

The one change I would suggest is to simply comment out the code in the Up and Down methods until you have deployed the migration. After that, you can uncomment the code and that will allow you to create a new database if you need to later.

这篇关于如何在EntityFramework 4.3中为现有数据库创建迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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