AutomaticMigrationsEnabled为false或true? [英] AutomaticMigrationsEnabled false or true?

查看:1480
本文介绍了AutomaticMigrationsEnabled为false或true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



更多声明:


$在EF项目中,是否有最佳做法设置 AutomaticMigrationsEnabled ? b $ b

在我们的团队修改模型之后,我们通常在Package Manager Console中运行add-migration和update-databse命令。当其他开发人员运行该项目时,会出现此错误:


无法删除数据库,因为它正在使用


每次发生这种情况,第一个修饰符应该是检入整个项目,而其他必须 GET 修改的对象。在许多情况下,我们不想检查已经创建的模型和迁移!



这种情况令人烦恼,有没有解决这种问题的办法。
提前感谢

解决方案

自动迁移对您来说都是魔术,但不允许严格的版本控制您没有针对每个版本进行特殊的固定迁移)。没有严格的版本控制,您无法跟踪数据库的版本,您无法进行显式升级(根本不能执行降级)。



如果您不打算使用版本控制您需要知道数据库是什么版本,如果您不打算使用降级,您可以简单地使用自动迁移。


可以不要删除数据库,因为它正在使用


看起来你正在使用共享数据库= show塞。每个开发者应该使用自己的数据库。


但不想结帐已经创建的模型和迁移!


这是一个最佳做法,如果你想继续基于代码的迁移,你将不得不遵循它。顺便说一句。有一种称为持续集成的练习 - 在连续集成中,您应该在提交成功构建并通过测试后立即获得。


In EF projects, Is there any best practice for setting AutomaticMigrationsEnabled ?

More declaration:

In our team after modifying a model we usually run "add-migration" and "update-databse" commands in Package Manager Console. This error raises when other developers run the project:

"Can not drop database because it is in use"

Every time this happen the first modifier should Check In whole project and others have to GET modified objects. In many cases we don't want to check in the already created model and migration!

This situation is annoying,are there any solution for this kind of problems. thanks in advance.

解决方案

Automatic migrations do all the magic for you but they don't allow strict versioning (you don't have special fixed migration for each version). Without strict versioning you cannot track version of your database and you cannot do explicit upgrades (you cannot do downgrades at all).

If you don't plan to use versioning where you need to know what version the database is and if you don't plan to use downgrading you can simply use automatic migration.

"Can not drop database because it is in use"

It looks like you are working on the shared database = show stopper. Each developer should use his own database.

but don't want to checkout the model and migration that was already created!

That is a best practice and if you want to continue with code based migrations you will have to follow it. Btw. there is a practice called "continuous integration" - in continuous integration you should get immediately after the commit is successfully built and passes tests.

这篇关于AutomaticMigrationsEnabled为false或true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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