it:ad:code_first:howto:work_with_enums

IT:AD:EF/CodeFirst:HowTo:Work with Enums

  • Enum support was introduced in EF5 (VS2012 targets it already)
  • Enums can be mapped to byte, int16, int32, Int64, SByte

using System.Data.Entity;

enum Sex {Undefined, Unknown, Male, Female}

public Person { 
  Sex Sex {get;set;}
}



Done. Works as one would expect. Saves to a db table with an int or byte column. Transparent.

  • /home/skysigal/public_html/data/pages/it/ad/code_first/howto/work_with_enums.txt
  • Last modified: 2023/11/04 03:39
  • by 127.0.0.1