Creating Relationship Between Multiple Tables in LightSwitch 2012

Here we will see about how to establish relationship among multiple tables using LightSwitch in Visual Studio 2012.

Steps for showing relationship among multiple table in LightSwitch 2012

Step 1

Open the Solution Explorer.

sol explo.jpg

Step 2

In the Solution Explorer, right click on the data source and choose Add Table option.

add table.jpg

Step 3

The Table appears. In this way we are going to create three tables (Customer, Item and CustomerItemMap).

Customer Table

customertab.jpg

Item Table

itemtab.jpg

CustomerItemMap Table doesnot not contain any data.It means the table is empty

customerItemmap tab.jpg

Step 4

Under the Item Table, select the ItemDescription from the Table and go to the property window.

itemtab.jpg

In the property window, clear the Maximum Length value.

Prop win.jpg

Step 5

Now we need to create the relationship. In order to create the relationship first select the CustomerItemMap table and click on the relationship button as shown

customeritemmap table relationship.jpg

Step 6

Add New Relationship window will appear.

empty relation.jpg

Step 7

Now we will create one to many relationship between the Customer and CustomerItemMap tables.

add new relationship customer.jpg

When we click "OK" button.

relation customer.jpg

Similarily between the Item and the CustomerItemMap tables.

new relationship item.jpg

When we click OK button.

Step 8

Now the relationship between the following tables is set. 

relationship shown.jpg


Similar Articles