【发布时间】:2011-05-16 09:18:19
【问题描述】:
我在 ASP.NET MVC 3 Web 应用程序中使用实体框架“代码优先”方法。在我的数据库中,我有几个计算列。我需要使用这些列来显示数据(效果很好)。
但是,当我在此表中插入行时,出现以下错误:
“ChargePointText”列不能 修改,因为它要么是 计算列 or 是 a 的结果 UNION 运算符。
有没有办法在我的班级中将该属性标记为只读?
public class Tariff
{
public int TariffId { get; set; }
public int Seq { get; set; }
public int TariffType { get; set; }
public int TariffValue { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public int ChargePoint { get; set; }
public string ChargePointText { get; set; }
}
【问题讨论】:
-
是的,你是对的 - 我的回答不正确。仅当您希望 EF 生成数据库时,它才起作用。发布您的更新作为答案并接受它。
标签: entity-framework ef-code-first entity-framework-4.1