How to: Define Data Fields
You can add fields to an entity or a table in the LightSwitch database. You can also modify the appearance and behavior of these fields.
This topic contains the following sections:
For a related video demonstration, see How Do I: Format Data on a Screen in a LightSwitch Application?.
You can add fields to a table. In an entity that is generated from an external data source, you can add computed fields only.
For more information about computed fields, see How to: Add a Computed Field.
To add a data field
In Solution Explorer, double-click an entity or table.
The entity or table opens in the Data Designer.
In the Name column, click <Add Property>, and then type a name for the field.
In Type column, select a data type for the new field. The following table describes each type.
Visual Basic Type
-128 to 127.
An array of bytes that has a variable length.
True or false.
A DateTime that is treated as a date only.
12:00:00 AM, Jan 1, 0001 through 11:59:59 PM, Dec 31, 9999.
±1.0 × 10<sup>−28</sup> to ±7.9 × 10<sup>28</sup>.
A fixed decimal point with 28-29 significant digits; good for accounting numbers.
±5.0e−324 to ±1.7e308.
A floating decimal point with 15-16 digits precision; good for scientific numbers.
A string that is treated as an email address.
A binary that is treated as an image.
-32,768 to 32,767.
A signed 16-bit integer.
-2147483647 to 2147483647.
A signed 32-bit integer.
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
A signed 64-bit integer.
A decimal that is treated as a monetary value.
A string that is treated as a phone number.
A sequence of zero or more Unicode characters that has a variable length.
If you want to require users to provide a value for this field, select the Required check box.
You can modify a field by editing the properties of the field in the Properties window.
If the entity was generated from an external data source, some field properties will not be editable because they reflect configuration settings of the data source.
LightSwitch does not enable you to override those settings by changing field properties. You must make changes to these fields on the server and then import those changes into LightSwitch by refreshing the data source.
To modify a field
In the Data Designer, click the field that you want to modify.
On the View menu, click Properties Window.
In the Properties window, set property values.
For more information about each property, see Reference: Data Designer Properties.