如何在 codefirst 映射中映射枚举属性?
我的枚举:
public enum GenderType : int
{
Male = 0,
Female = 1
}
我的模特
public string City { get; set; }
public string Country { get; set; }
public string Occupation { get; set; }
public string WebsiteURL { get; set; }
public GenderType Gender { get; set; }
public int gender { get; set; }
public GenderType Gender
{
// 不工作:不能隐式转换类型 int .... get { return gender; } 设置 { 性别 = (int) 值;} }
我的配置
Property(model => model.Comment)
.HasMaxLength(4000)
.IsUnicode();
Property(model => model.Culture)
.IsOptional()
.HasMaxLength(10);
----- HOW TO WRITE GENDER?