实体框架CTP 5 - 代码优先映射 - 无法正确映射枚举列表 [英] Entity Framework CTP 5 - Code First Mappings - Can't map properly an enum list

查看:109
本文介绍了实体框架CTP 5 - 代码优先映射 - 无法正确映射枚举列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下

[DataContractAttribute]
public class Animal
{
    [Key]
    [XmlElement(ElementName = "Id")]
    [DataMember()]
    public Guid Id
    {
        get;
        set;
    }

    [XmlElement(ElementName = "AnimalType")]
    [DataMember()]
    public List<AnimalType> AnimalType
    {
        get;
        set;
    }
 }

我将其通过代码第一个方法映射到EF到表

And i map it through the code first approach with EF to tables

  modelBuilder.Entity<Animal>().ToTable("Animal");

如你所见,我没有执行一些复杂的映射,但是AnimalType枚举列表没有被映射自动到DB中的任何列/表。我需要向模型构建器添加一些额外的代码来控制枚举列表的映射吗?

As you see I have not performed some complex mapping, but the List of AnimalType enumerations did not get mapped automatically to any columns/tables in the DB. Do i need to add some extra code to the model builder to control the mapping of an enumeration list ?

推荐答案

从EF CTP5开始,枚举尚未支持。该团队宣布将在2011年第一季度发布的下一个RTM版本中完全支持枚举。

As of EF CTP5, enums are not supported yet. The team announced that they are going to fully support enums in their next RTM version which is targeted to be released on the first quarter of 2011.

这篇关于实体框架CTP 5 - 代码优先映射 - 无法正确映射枚举列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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