Here we will see how to create a table as well as establish a relationship between tables in LightSwitch using Visual Studio 2012.This article describes how to establish a relationship between tables.
Step 1Open the Solution Explorer.Step 2In the Solution Explorer, right-click on the Server and choose "Add Table". Step 3Here we will add three tables as in the following.Company TableEmployee TableProject TableStep 4Now we will add a relationship between the tables.To add a relationship between the tables go to the menu bar and click on the Add Relationship button.The Add New Relationship dialog box appears. In that, establish the relationship in such a way that one Company can have more than one Employee.One Employee can have more than one project.Step 5In the Solution Explorer, right-click on the Screens and choose "Add Screen".The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, under screen information, choose "Company" under screen data and provide some name to the Screen and click "OK" button.In this way we will add two more Editable Grid Screens, one for Employee and another for the project.The Editable Project Screen is shown below.Step 6Press F5 to run the application. The output for the Editable Employee Grid:The output for the Editable project Grid is shown below.