Can I store enums as strings in EF 5?

后端 未结 2 1846
面向向阳花
面向向阳花 2021-01-04 00:29

We have been using EF CF for a while in our solution. Big fans! Up to this point, we\'ve been using a hack to support enums (creating an extra field on the model; ignore the

2条回答
  •  自闭症患者
    2021-01-04 01:23

    This is currently not possible. Enum in EF has same limitations as enums in CLR - they are just named set of integer values. Check this article for confirmation:

    The EF enum type definitions live in conceptual layer. Similarly to CLR enums the EF enums have underlying type which is one of Edm.SByte, Edm.Byte, Edm.Int16, Edm.Int32 or Edm.Int64 with Edm.Int32 being the default underlying type if none has been specified.

    I posted article and related suggestion about this problem. If you want to see this feature in the future please vote for the suggestion.

提交回复
热议问题