我想扩展一个带有临时属性的实体框架模型。 我只需要一个mvc形式。我不需要将其保存在数据库中。
我该怎么做?
答案 0 :(得分:5)
为要扩展的实体创建一个分部类
e.g。
//must be in the same namespace as the Customer entity in the model
public partial class Customer
{
public string MyProperty{get;set;}
}
此属性将取消映射,您可以在运行查询或实现后填充数据。
OR
为您的实体创建一个包装类,它将未映射的属性和映射的属性公开在视图中所需的属性。