实体框架4.2枚举支持 [英] Entity Framework 4.2 enum support

查看:136
本文介绍了实体框架4.2枚举支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,EF 4.2 Code First是否支持枚举类型?如果是这样,你如何使用它?在使用Nuget EntityFramework包时,以下内容不会为枚举属性创建一个字段。

  public class FooContext:DbContext 
{
public IDbSet&Foo> Fo子组; }
}

public class Foo
{
public int Id {get;组; }
public string Name {get;组; }
public Category Category {get;组;
}

public enum类别{一,二,三}

var db = new FooContext();
db.Foos.ToList();


解决方案

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


Does EF 4.2 Code First have support for enum types? If so, how do you use it? The following does not create a field for the enum property when using the Nuget EntityFramework package.

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();

解决方案

EF team has changed versioning so EFv4.2 is not final release of June 2011 CTP. Features from June 2011 CTP should be released as part of .NET Framework 4.5.

这篇关于实体框架4.2枚举支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆