Powered by Zoomin Software. For more details please contactZoomin

DataDirect Connect for ADO.NET Data Provider Help

Using Enumerations with the ADO.NET Entity Framework

Using Enumerations with the ADO.NET Entity Framework

  • Last Updated: April 16, 2026
  • 2 minute read
    • ADO.NET
    • Documentation

The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type. By default, every underlying type of the enumeration element is mapped to type int32. By default, the first enumerator has the value 0, and the value of each consecutive enumerator is incremented by 1. For example, you would specify a days-of-the-week enum type as:

enum Days {MON, TUE, WED, THU, FRI, SAT, SUN};

In this enumeration, MON would be 0, TUE 1, WED 2, and so forth. Enumerators can have initializers to override the default values. For example:

enum Days {MON=1, TUE, WED, THU, FRI, SAT, SUN};

In this enumeration, the sequence is forced to start at 1 instead of 0. Because they are constants, the names of an enum type's fields are in uppercase letters.

Enumerations are supported in all three workflows, namely, Model First, Code First, and Database First.

In Entity Framework, an enumeration can have the following underlying types:

  • Byte
  • nt16
  • Int32
  • Int64
  • SByte

By default, the enumeration is of type Int32. Another integral numeric type can be specified using a colon.

enum Days : byte{MON=1, TUE, WED, THU, FRI, SAT, SUN};

The underlying type specifies how much storage is allocated for each enumerator. However, an explicit cast is needed to convert from enum type to an integral type. Enum implementations also support type mapping changes. See Mapping Data Types and Functions for more information.

As part of Entity Framework, Entity Developer fully supports enum types by providing a new Enum node in its Model Explorer window. You can use the Enum property just like any other scalar property, such as in LINQ queries and updates.

TitleResults for “How to create a CRG?”Also Available inAlert