如何使用Code First在数据库中保存静态成员?
例如:
public class Department
{
/// <summary>
/// </summary>
public static int TotalLevelNumber;
public int Id { get; set; }
/// <summary>
/// </summary>
public int Level { get; set; }
/// <summary>
/// </summary>
public string Name { get; set; }
/// <summary>
/// </summary>
public Department ParentDepartment { get; set; }
/// <summary>
/// </summary>
public List< Department> SonDepartment { get; set; }
}
TotalLevelNumber
是一个静态成员,代表总级别数。当TotalLevelNumber
= 4时,所有Department
实例只能拥有1-4中的属性Level
。我想将TotalLevelNumber
保存到数据库中。怎么做?现在的情况是Code First不会生成关于TotalLevelNumber