C# – Mapping Enum Types to Entity Properties in the Entity Framework Designer

Enums have implicit numeric indicies.

public enum BallType{
Baseball = 0,
Basketball = 1,
Football = 2
}

You can change the “seed”:
Implies 1, 2, 3

public enum BallType{
Baseball = 1,
Basketball,
Football
}

The Entity Framework Designer maps enums to int data types.

In Entity Data Model Diagram(edmx)
– Right-click column
– Select convert to enum
– In the Add Enum Type dialog, either:
— Select reference external type, enter namespace + type, or…
— Enter Enum type name, enter Members and optional values

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: