Skip to main content
A newer version of this page is available. .

Boolean Properties in Entity Framework

The example below illustrates how to implement Boolean Properties in an Entity Framework Code-First class.

// By default, a Boolean property is displayed via a CheckEdit control.
public bool BooleanProperty { get; set; }
// To use a drop-down control, specify captions with the CaptionsForBoolValues attribute.
[CaptionsForBoolValues("TRUE", "FALSE")]
public bool BooleanWithCaptions { get; set; }
// To display images in a drop-down, apply the ImagesForBoolValues attribute.
[ImagesForBoolValues("ImageForTrue", "ImageForFalse")]
[CaptionsForBoolValues("TRUE", "FALSE")]
public bool BooleanWithImages { get; set; }

You can also specify captions and images via the following properties in the Model Editor: