实体框架4.2枚举支持

Sea*_*ron 6 entity-framework-4

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();
Run Code Online (Sandbox Code Playgroud)

Lad*_*nka 9

EF团队已经更改了版本,因此EFv4.2不是2011年6月CTP的最终版本.2011年6月的功能CTP 应作为.NET Framework 4.5的一部分发布.