【发布时间】:2011-11-02 08:10:31
【问题描述】:
EF 4.2 Code First 是否支持枚举类型?如果是这样,你如何使用它?以下在使用 Nuget EntityFramework 包时不会为枚举属性创建字段。
public class FooContext : DbContext
{
public IDbSet<Foo> Foos { get; set; }
}
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
public Category Category { get; set; }
}
public enum Category {One, Two, Three }
var db = new FooContext();
db.Foos.ToList();
【问题讨论】: