The Enum designer opens after you select the "Enum Design" in Add New Item. It allows you to create and configure an enumerator that contains fixed set of constants for use as an enumerated type in entities.
You can configure the following basic settings for the enumerator in the Enum designer:
- Display Name: The display name of the enum type.
- Is a [Flags] enum: Whether the enum type is defined as flags (i.e. can be treated as a bit field). For more information, refer to Bit operation enum.
- Description: The description of the enum type, which appears as a comment in the C# code.
You can configure the following basic settings for the field in the Enum designer:
Add field: Clicks to add a member and value to the enumerator.
Name: The name of the enum member.
Display Name: The display name of the enum member.
Value: The value of the enum member.
Description: The description of the enum member, which appears as a comment in the C# code.
Bit operation enum
Bit operation enumeration is mainly used in scenarios where an item can have multiple states at the same time.
For example, EF Core documents belong to the EF Core category, and also belongs to the .NET category.
To create a bit operation enum for this example, you specify the settings as follows:
Select the Is a [Flags] enum option. The enum type becomes the bit operation enum type.
Specify the value of the bit operation enum type. The value must meet the following rules: greater than 0, no repetition, and 2 to the nth power.
Then it can be assigned with multiple values: