如何禁用迁移实体框架 [英] how to disable migration entity framework

查看:100
本文介绍了如何禁用迁移实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





如何禁用我的项目数据库中的迁移实体框架bcz是为给定的datacontext名称自动创建的请给我代码如何禁用迁移并在我的表中引用我自己的数据库







我的邮件地址: - [删除电子邮件]

解决方案

请通过以下链接



http://stackoverflow.com/questions/18667172/how-can-i-disable -migration-in-entity-6-0 [ ^ ]



http://www.entityframeworktutorial.net/code-first/turn-off-database-initialization-in-cod e-first.aspx [ ^ ]



http://stackoverflow.com/questions/9703810/how-to-disable-migration-in-entity-framework-4-3-1 [ ^ ]


所以问题似乎是如何通过EntityFramework完全禁用数据库创建。



最简单的方法是通过为给定的上下文类型设置 null 来禁用初始化程序。



 Database.SetInitializer< YourContext>( null ); 





一个简单的方法可以是将此代码放在静态c中派生背景的onstructor。



这就是你要找的东西吗?



亲切问候



约翰内斯


别忘了运行:



< pre lang =c#> update-database


hi to all,


How to disable Migration entity framework bcz in my project database is automatically created for given datacontext name so kindly send me code how to disable Migration and refer my own database in my table



my mail address:- [email removed]

解决方案

Please go through below links

http://stackoverflow.com/questions/18667172/how-can-i-disable-migration-in-entity-6-0[^]

http://www.entityframeworktutorial.net/code-first/turn-off-database-initialization-in-code-first.aspx[^]

http://stackoverflow.com/questions/9703810/how-to-disable-migration-in-entity-framework-4-3-1[^]


So the question seems to be how to completly disable database creation through EntityFramework.

The easiest is to disable the initializer by Setting it null for a given context type.

Database.SetInitializer<YourContext>(null);



An easy Approach could be to place this code in a static constructor of your derived context.

Is this what you was looking for?

Kind regards

Johannes


Don't forget to run:

update-database


这篇关于如何禁用迁移实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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