Tinyint(byte),SmallInt(Int16) not compatible with Enum in EF5

前端 未结 2 1108
余生分开走
余生分开走 2021-02-05 04:48

Using Database first design and having tinyint (or smallint) column:

[MyEnumColumn] [tinyint] NOT NULL

I mapped this column to Enum Type in EDM

2条回答
  •  春和景丽
    2021-02-05 05:18

    You need to specify both in the Model and in the Enumerator that you are using tinyInt and Byte .

    in Enumerator definition public enum MyEnumType : byte { One, Two, Three, All }

    then in the Model class file

     [Column(TypeName = "tinyint")]
        public MyEnumType? MyEnum { get; set; }   
    

提交回复
热议问题