【发布时间】:2013-07-05 07:30:19
【问题描述】:
如何在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 .... 获取{返回性别; } 设置{性别=(int)值; } }
我的配置
Property(model => model.Comment)
.HasMaxLength(4000)
.IsUnicode();
Property(model => model.Culture)
.IsOptional()
.HasMaxLength(10);
----- HOW TO WRITE GENDER?
【问题讨论】:
标签: .net visual-studio-2012 ef-code-first code-first entity-framework-migrations