Establishing Relationship Between Two Tables in LightSwitch 2012

This article describes creation of a relationship between tables in LightSwitch using Visual Studio 2012.

Procedure for creation of a relationship in LightSwitch 2012.

Step 1

In the LightSwitch Application, open the Solution Explorer.

solution.jpg

Step 2

Right-click on the data source and choose "Add table".

add table.jpg

Step 3

Here we will add two tables.

Emp Table:

emp table.jpg

Item Table:

item table.jpg

Step 4

Select the "Relationship" button form the menu bar.

add relationship.jpg

The Add New Relationship dialog box appears. Establish the relationship between the "Item" and "Emp" tables.

relationship dialog.jpg

Step 5

The Application Designer appears.

relationship new.jpg

Step 6

Go to the Solution Explorer, right-click on the screen and choose "Add Screen".

add src.jpg

The New Screen Designer appears. Select a New Data Screen template and under Screen Data choose "Emp". You can provide a Screen Name of your choice and click the "OK" button.

new screen.jpg

Step 7

The screen designer appears.

Step 8

Add a new "Search" Screen and under Screen Data choose "Emp" and click the "OK" button.

search emp.jpg

Step 9

Press F5 to run the application. Insert some value into the fields and click the "Save" button.

You will see that you can easily find the data in the Search Screen.

new out 2.jpg


Similar Articles