This documentation is archived and is not being maintained.

Step 2: Define the Data

In this lesson, you will define the data for your contact management application by creating a table, also known as a data entity. You will use the LightSwitch Data Designer to specify the property fields and data types that represent a contact.

To create an entity for your application

  1. In the My First Application Designer window, click Create new table.

    The Data Designer window opens.

  2. In the Properties window, select the Name property and type Contact, and then press Enter.

    Notice that the name in the title bar changes to "Contact" and that the name in Solution Explorer changes to "Contacts".

  3. In the Name column click <Add property> and type ContactName, and then press Enter.

    Notice that the appropriate data type, String, appears in the Type column, and that the Required field is checked. A contact must have a name.

  4. Click <Add property> in the Name column and type ContactCompany.

  5. Click <Add property> in the Name column and type ContactPhone.

  6. In the Type column, select PhoneNumber from the drop-down list.

    PhoneNumber is a custom business type that represents a common pattern for entering and formatting telephone numbers.

  7. Click <Add property> in the Name column and type ContactEmail.

  8. In the Type column, select EmailAddress from the drop-down list.

    EmailAddress is another custom business type that represents a correctly formatted e-mail address.

  9. In the Required column for the ContactEmail field, clear the check box.

    In this case, you want to be able to enter a contact without an e-mail address.

    At this point, your entity should look like the following illustration:

    The completed data entity

You just created a data entity that contains four fields. As you enter and save data in your contact management application, the entries in those fields are stored in an internal database.

When you defined the data in your data entity, you used custom business types for the telephone number and e-mail address. Custom business types are a convenient way to specify complex data that is typically used in business applications. Because many custom business types are already defined, you do not have to worry about implementation details for generally used data.

In addition to the custom business types built into LightSwitch, additional types are available as extensions. You will learn more about extensions in a later lesson.

In the next step, you will learn how to create a screen to display and edit the data.

Next lesson: Step 3: Create a Screen

Show: