Product Review: Visual Studio LightSwitch

Although Visual Studio LightSwitch uses the same development environment as other Microsoft .NET development tools, it takes a very different approach to application development.

William Sheldon

February 24, 2012

5 Min Read
ITPro Today logo

Microsoft Visual Studio LightSwitch is a new tool for building distributed business applications. The fact that the product includes "Visual Studio" inits name tells you that it uses the same development environment as other Microsoft .NET development tools. However, LightSwitch takes a very differentapproach to application development.

In a traditional application development project, you typically start by creating an initial screen, after which you tie a data source to the screen.In LightSwitch, you start by defining your data source, after which you create a screen against that data source. LightSwitch is about enabling accessto data. The source of that data can be a SQL Server database, SharePoint list, or Windows Communication Foundation (WCF) Rich Internet Application(RIA) Services.

As the Solution Explorer pane in Figure 1 shows, the LightSwitch project structure differs from the traditional application project structure in thatyou have two default folders. The Data Sources folder stores connection information, XML Schema Definitions (XSDs), and other information related tothe data sources. As you generate screens, they'll be stored in the Screens folder.

 
Figure 1: LightSwitch project structure

Clicking the Attach to external Data Source option in the screen in Figure 1 launches a wizard that walks you through configuring a datasource. For this review, I used an existing SQL Server database as a data source. There are two limitations in doing so. First, LightSwitch doesn'tsupport stored procedures. Second, if an existing table doesn't have a primary key, the table's data will be read-only, as Figure 2 shows. So, ifyou're new to LightSwitch, I suggest that you start by creating a new database. That way, LightSwitch will automatically provide an integer primary keyfor each new table, which you can use as a foreign key between tables.


Figure 2: Warning message about the consequences of not having a primary key 

Creating the screens that will be used to access the data is straightforward because the screens are based on templates. Typically, you use theLightSwitch templates, but you can create new templates or import third-party templates. Because you're using templates, you can leverage the highlyscalable tools upon which LightSwitch is built -- the ADO.NET Entity Framework, Extensible Application Markup Language (XAML)-based Silverlight, andWCF RIA Services -- without needing to understand their details.

Aside from changing the order of data fields, there are limited options for template customization out of the box. However, one of the main reasonsLightSwitch is classified as a developer tool is its extensibility. To customize the layouts, you can work with a developer who is familiar with XAML.The developer can leverage the LightSwitch SDK to create custom UI elements. The SDK is available as a free download.

Besides being able to customize the templates and their layout, developers can create custom data sources and custom data types. The latter isimportant when you use a SQL Server database as a data source. Instead of adding base SQL Server data types to work with databases, LightSwitch adds afew custom data types (e.g., data types for phone numbers and email addresses) that are implemented in the data layer above SQL Server. Using the SDK,it's possible to create additional custom data types.

The ease with which templates are generated and later customized makes LightSwitch an excellent prototyping tool. You can define a set of data tablesintegrated with services and generate a basic UI that lets you test data-entry assumptions. You can use this prototype for a quick win, then introducemore customizations to meet additional business needs on subsequent generations of the application.

You can deploy LightSwitch applications on the desktop, on the web, or in Windows Azure. However, when deploying LightSwitch applications internally,keep in mind that users' desktops or the web server will need to have the LightSwitch runtime DLL installed. LightSwitch doesn't just generate compiledcode. It uses metadata to define the UI, and it's the runtime DLL that understands how to emit the correct code to power the interface.

By default, LightSwitch uses the Active Directory (AD) infrastructure to provide base security. It's also possible to create custom rules withinLightSwitch related to the application. These rules live within the application configuration and get deployed with the application.

Although LightSwitch is a new development tool, there's already a lot of documentation for it. MSDN's LightSwitch Developer Center(msdn.microsoft.com/en-us/lightswitch) includes documentation, videos, samples, and blogs. In particular, Beth Massi's blogs(blogs.msdn.com/b/bethmassi) provide detailed step-by-step examples of how to build powerful business applications that look great using LightSwitch.You can also use the Visual Studio Extension Manager to download existing custom themes, data types, and related tools.

Despite the abundance of documentation, developers might approach LightSwitch with trepidation for two reasons:

  • They might feel that their skills are being underutilized. In its current version, LightSwitch probably isn't the tool developers will want touse to create a new dynamic UI. However, it provides a simple yet powerful development environment for creating departmental applications.

  • They might think of LightSwitch as a "Fisher-Price" development tool that will create hard-to-transition applications -- that is, once you buildan application with it, transitioning that application to .NET would be difficult or require a complete rewrite. However, LightSwitch isn't a languageor a closed development paradigm. It leverages technology sets (e.g., ADO.NET Entity Framework, XAML-based Silverlight) that are available to and usedby professional developers. LightSwitch applications are customizable using C# or Visual Basic. They're also fully extensible both under the covers andwith external UIs and controls. Although LightSwitch applications might not be ready to become the next Amazon.com, they do help businesses meet theneed of creating effective applications on a limited budget.

If you're a DBA who needs a simple way to build effective UIs for your corporate data, you might want to check out some completed screens from thesample LightSwitch application at www.codeproject.com/Articles/318840/Data-Centre-A-Product-Information-and-Promotion-Ma. If you're a developer who hassome reservations about LightSwitch, be sure to read about the developer's experiences when building this application.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like