How to: Define Data Fields in a LightSwitch Database
You can add fields to an entity or a table in the LightSwitch database and 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's generated from an external data source, you can add computed fields only.
To add a data field
In Solution Explorer, open the shortcut menu for an entity or table, and then choose Open.
For applications that have been upgraded to Visual Studio 2012 Update 2, on the Perspective bar, choose the Server tab.
The entity or table opens in the Data Designer.
In the Name column, enter a name for the field.
In Type column, choose 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's 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's treated as an email address.
A string that's formatted as a globally unique identifier (GUID). The value is automatically generated for each record.
A binary that's 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's treated as a monetary value.
A decimal that's treated as a percentage.
A string that's treated as a phone number.
A sequence of zero or more Unicode characters that has a variable length.
A string that's treated as a web address (URL).
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 its properties in the Properties window.
If the entity was generated from an external data source, you won't be able to edit some field properties because they reflect configuration settings of the data source.
You can't 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, choose the field that you want to modify.
In the Properties window, set property values.