忽略实体框架中的特定列? [英] Ignore a specific column in Entity Framework?

查看:51
本文介绍了忽略实体框架中的特定列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Entity Framework版本4.1.10331.0中的数据库中自动生成了模型。

I have auto generated model from a database in Entity Framework version 4.1.10331.0.

我想忽略实体中的一列,而无需使用Fluent Api,也无需将 ObjectContext 更改为 DbContext (当然也不会从SQL表中删除该列),也不会使用属性 NotMapped ,因为每当我在模型中更新上下文时,该列就会重新出现。

I want to ignore a column from an entity without using the Fluent Api and without changing the ObjectContext into DbContext (and of course without deleting the column from the SQL table) and without marking the property generated in the model with the attribute NotMapped, because whenever I update my context in the model that column will reappear.

在这种情况下,有人可以帮助我吗?

Can someone please help me in this case?

Ben致以最诚挚的问候

Thanks and best regards Ben

推荐答案

每次重新生成EF时,我都看不到更新EF的问题模型,但我可以提出2个解决方案:

I don't see the problem updating your EF each time you regenerate the model, but I can propose 2 solutions:


  1. 创建一个包含所需列的视图,然后在EF中生成它。

  2. 创建另一个从您的实体派生的类,该类将显示所需的数据。此类将是您的应用程序实体(如您所知,应在此处考虑其他管理)

  1. Create a View that contains the columns you need, then generated it in EF.
  2. Create another class derived from you entity that will show the data you want. This class will be your "application Entity" (As you know additional management should be considered here)

这篇关于忽略实体框架中的特定列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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