在实体中创建非映射属性(实体框架) [英] Creating a non mapped property in an entity (entity framework)
本文介绍了在实体中创建非映射属性(实体框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
使用部分类添加要添加的属性或方法。例如
命名空间WhateverNamespaceYourEntityModelIsIn
{
public partial class TheNameOfYourEntity
{
public string MyNewProperty {get;组; }
}
}
I want to create a custom property on one of my entities mapped from the database, however this property is not mapped to the database, I created the property using partial classes but when trying to compile I get an error telling me that the property is not mapped. Is there an attribute or something I should add? Thanks in advance.
解决方案
Use partial classes to add the properties or methods you want added. E.g.
namespace WhateverNamespaceYourEntityModelIsIn
{
public partial class TheNameOfYourEntity
{
public string MyNewProperty { get; set; }
}
}
and that should do you.
这篇关于在实体中创建非映射属性(实体框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文