【发布时间】:2012-07-23 16:45:58
【问题描述】:
我在 Entity Framework 4.0 中使用代码优先模式。我希望数据库中的某些列具有默认值。
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
//I need some kind of attribute like this
[ColumnAttribute.Default = false]
public bool IsEnabled { get; set; }
}
我正在寻找一种方法来将 IsEnabled 列的默认值定义为 false。
【问题讨论】:
-
布尔值的默认值已经是
false。对于其他默认值,请参阅答案。
标签: .net entity-framework ef-code-first