如何在实体框架中从自动代码优先迁移中排除一个表? [英] How to exclude one table from automatic code first migrations in the Entity Framework?

查看:85
本文介绍了如何在实体框架中从自动代码优先迁移中排除一个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在启用自动迁移的代码优先模式下使用实体框架。现在,我有一个实体,其表不应由EF管理(迁移)。有没有一种方法可以禁用一个特定实体(即表)的自动迁移?

I'm using the Entity Framework in the Code First mode with automatic migrations enabled. Now, I have one entity whose table should not be managed (migrated) by the EF. Is there a way of disabling automatic migrations for one specific entity (i.e. table)?

推荐答案

可以通过使用另一个 DbContext 来访问相关表。迁移绑定到一个 DbContext (请参见)。

It is possible by using another DbContext to access the table in question. Migrations are bound to one DbContext (see Is it possible to have automatic migrations for one DbContext and not for another in the same project?).

这篇关于如何在实体框架中从自动代码优先迁移中排除一个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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