Adding a Relationship Between Tables in the LightSwitch Internal Database

How to add a relationship between tables in LightSwitch internal database

In this article I describe how to use the LightSwitch data designer to add a relationship between two tables in the LightSwitch internal database.

The following describes the procedure for adding a relationship between tables in Visual Studio 2012 LightSwitch.

Step 1

Open the Solution Explorer.

Image 1

relation solex.jpg

Step 2

In the Solution Explorer, double-click or right-click on the table to open it.

Image 2

tabopen.jpg

Step 3

The table opens in Data Designer.

Image 3

table1.jpg

Step 4

In the Data Designer on the command bar go to the relationship button.

Image 4

relationshipbutton.jpg

Step 5

The "Add New Relationship" dialog box appears.

Image 5

relationship dialog.jpg

Step 6

In the Add New Relationship dialog box, go to the Name row and choose the two tables for which we want to apply a relationship (for example, EmployeeTabs and ProductTables).

Image 6

afterselectingname.jpg

Step 7

In the multiplicity row we specify how we want these tables to be related. See http://msdn.microsoft.com/en-us/library/vstudio/ff852044.aspx#Multiplicity

Image 7

Multiplicity.jpg

Step 8

On the Delete Behavior row we specify what we want our application to do if a user tries to delete a record in one table but data still exists in the related record in the other table. See: http://msdn.microsoft.com/en-us/library/vstudio/ff852044.aspx#Deletion

Image 8

deletebehaviour.jpg

Step 9

In the Navigation Property row, enter a name for each navigation property, and then choose the "OK" button. The Navigation properties help users to navigate among areas of a screen that display related data. 

Image 9

deletebehaviour.jpg

Step 10

Since we began debugging we have the following output:

Image 10

relationshipoutput.jpg


Similar Articles