EF5不会创建枚举列

EF5不会创建枚举列

本文介绍了EF5不会创建枚举列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个模型:

namespace Ad.NegCred.Data.Model {
    public enum DataKind {
        F, //Takibe alınıp henüz tahsil edilmeyen ferdi kredi bildirimi
        FA, //Aynı dönemde takibe alınan ve tahsil edilen ferdi kredi bildirimi
        FF, //daha önceki dönemlerde takibe alındığı bildirilmiş ferdi kredi tahsil bildirimi
        K, //Takibe alınıp henüz tahsil edilmeyan kredi kartı
        KA, //Aynı dönemde takibe alınan ve tahsil edilen kredi kartı
        KF //Daha önceki dönemlerde takibe alındığı bildirilmiş kredi kartı tahsil    bildirimi
    }

    public class Datum {
        [Key]
        public long Id { get; set; }
        public DataKind Kind { get; set; }
        [StringLength(25, MinimumLength = 2)]
        public string Name { get; set; }
    }
}

在由EF创建的数据库,所有列,但列被创建。另一个枚举列是这里没有显示,则不会创建以及复杂类型的一部分​​。

When database created by EF, all columns but the Kind column are created. Another enum column which is part of a complex type not shown here is not created as well.

为什么EF 5这样的表现?有没有,我不知道设置?

Why does EF 5 behave like this? Is there a setting that I do not know about?

推荐答案

您似乎使用EF5和目标的.NET Framework 4。这将自System.Data.Entity.dll中使用的EntityFrameork.dll不能处理枚举的.NET Framework 4不起作用。你要么需要移动到EF5和.NET Framework 4.5或EF6在这里你可以针对.NET Framework 4的并用枚举,因为EF6不依赖于运.NET框架组件了。

You seem to be using EF5 and target .NET Framework 4. This won't work since System.Data.Entity.dll in .NET Framework 4 used by the EntityFrameork.dll cannot handle enums. You either need to move to EF5 and .NET Framework 4.5 or to EF6 where you can target .NET Framework 4 and use enums since EF6 doesn't depend on components shipped in .NET Framework anymore.

这篇关于EF5不会创建枚举列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 15:31