First look at Microsoft Visual Studio LightSwitch

Illuminate Me

(See what I did there?)

Visual Studio LightSwitch is a new platform designed to make it simpler to create line-of-business applications for the desktop and the cloud.

It is currently in Beta 2 and can be downloaded from the Microsoft site free of charge.

LightSwitch contains pre-configured screen templates and other re-usable components to handle many routine business application tasks. You can write code in C# or VB.NET and deploy it to the desktop, web or Windows Azure.

So that’s enough of the marketing headlines, you can read plenty more of them on the official web site, let’s have a go at making something and see what it is really like….

 

Getting Started

Once you have downloaded and installed LightSwitch (you must have Visual Studio SP1 installed first), open Visual Studio and you will notice a new set of templates under LightSwitch.

 

lsNewProject

 

Choose your preferred language, give your app a name and click ‘OK’. This will take you to the LightSwitch Home Page (View > Home Page).

From the Home Page you can choose to connect to an existing external datasource, such as MS SQL Server (no support for Stored Procedures at present), SharePoint or a WCF RIA Service, or create a new table in an internal SQL Express database.

 

Defining the Data

Choose the ‘Create new table’ option and add the following fields:

Name Type Required
Surname String Y
Forenames String Y
Phone Phone Number Y
Email Email Address Y

Click the title of the table in the Data Designer or Properties Window and change it to “Contacts” and save the table.

 

lsDesignerToolbar 
Next, click the ‘New Table’ button in the Application Designer toolbar and create the following table and name it ‘Companies’:

Name Type Required
Name String Y
Address String Y
Town String Y
County String Y
Postcode String Y
RenewalDate Date Y

 

Finally, click the ‘Relationship…’ button in the Designer toolbar and configure the relationship as follows:

 

lsRelationships

 

Adding a Screen

When you click the ‘Screen…’ button in the Designer toolbar, you will be shown this dialog:

lsAddScreen

 

Choose a ‘List and Details Screen’ and set the Screen Data to ‘Companies Set’. Ensure that the check boxes to include both sets of additional data are checked and click ‘OK’ to add the screen to the application. This will take you to the Screen Designer, which displays a representation of the layout and commands for the screen:

 

lsScreenDesigner

But don’t worry about the Screen Designer right now – we can have a look at all that another day. For now let’s just run the application…

 

The Result

The application created for us by LightSwitch allows us to view our company contact data in a master-detail format and has a lot of functionality for very little effort:

 

 lsAppHome

 

We can add, edit and delete companies and contacts, as well as performing various other tasks such as searching and exporting:

 

lsAddCompany

 

And the user interface contains some basic validation, based on the data we defined:

 

lsValidation 

Conclusion

There has been a mixed reception to LightSwitch from the developer community, with many perhaps justifiably worried that it may lead to a new plaque of ‘Office Expert’ Access Forms-style mini-applications of the type that many organisations have tried so hard to eradicate. However, there is no doubting that this is a very impressive piece of technology that allow you to build a functional application very quickly.

As I mentioned at the beginning of the post, LightSwitch apps run in C# or VB.NET and can use a variety of datasources, so perhaps the instructions to the ‘Office Experts’ should be as Dave Mendlen, Microsoft Senior Director of Developer Tools and Platform Marketing suggests: “if you are going to go rogue, use LightSwitch”. That way at least it can be handed over to a more experienced .NET developer if necessary.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)