实体框架:添加不映射到数据库的属性 [英] Entity Framework: add property that don't map to database

查看:107
本文介绍了实体框架:添加不映射到数据库的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以向属性不应映射到数据库的实体添加属性?

Is it possible to add a property to an entity where the property is not supposed to map to the database?

推荐答案

可能?当然;将其添加到与您的实体类型匹配的自定义部分类。有用?不如您(主要)不能在LINQ to Entities查询中使用它们,您不应将您的实体重新定位为视图模型。

Possible? Sure; add it to a custom partial class matching your entity type. Useful? Less so; you (mostly) can't use them in LINQ to Entities queries, and you shouldn't re-purpose your entities as view models.

这篇关于实体框架:添加不映射到数据库的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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