Sunday 23 June 2013

LightSwitch

If you want to build a quick and simple application to display and edit data, then Microsoft has released a solution for you. LightSwitch. It has been around for a while but now it supports 2 interesting features.

HTML client and SharePoint support. Both of the features are immensely valuable because now we are talking about quick prototype applications for any platform and not just desktop client. 

LightSwitch applications support 4 types of data sources - Database, SharePoint List, OData service, WCF RIA service. OData service is something that has now been treated as a standard way of exposing data related operations on the Internet - mostly because it is easy to consume and is HTTP based (which means it can be consumed by most applications running on most devices such as Windows 8 Store Application, Windows Phone 8 application etc.).


If you plan to create tables instead of using existing data sources, you can use the option "Create Table" which presents with a screen to design the table/entity. These entities are created as part of a local database "ApplicationDatabase".



It comes with built-in implementation for data validation, access control (Forms authentication and Windows Authentication with basic settings to configure permissions) and you are allowed to customize the screens and their navigation. So, while on a high level it is a quick data editing application maker, it can as well be extended to create regular LOB applications. More so, the HTML applications can be hosted in SharePoint and distributed via SharePoint application store.

Compiling a LightSwitch application produces a package (deployable application) which contains a lot of generated code including WCF services, JavaScript files, CSS files, XAP files, config files and client access policy. I created a simple application which had 2 clients (HTML and Desktop) and package looked like following:



Since the generate package is a normal .NET application, we should be able to modify the configuration entries and point to different database servers, deploy the applicationdatabase on a separate server, host WCF service on a separate server and point the application to that. A quick search for ApplicationData.svc in the generated package pointed me to the location in the code (javascript file named data.js) where the URL was being formed. Ideally i should be able to change this and make it work (I haven't tried it but it should work if there is no other kind of hard binding in generated code):



Hoping to use it to create useful applications in double quick time.

Saturday 1 June 2013

SQL Collation mismatch error

I have been put through some grief a few times in last year due to issues caused by SQL collation mismatch. It happened across a few projects that worked on in that duration.

Each time it so happened that when we got ready to deploy the code to a different environment, SQL Server was deployed by a different team in a different geographical location. We provided deployment script and database backups for the databases present in our development environment. Invariably this caused a mismatch between the collation setting of the SQL Server Instance and the database and caused runtime errors complaining about the mismatch in collation.

The fix was pretty straightforward and in our case, a little less risky because the target environments were development and testing environments. The steps and commands are explained in detail here.

A few things to note are:

Do not forget to take backup of the existing databases. "Rebuilddatabase" option removes all the databases.
Default SQL Server Instance name is usually MSSQLSERVER.
User name is case sensitive. We struggled with administrator vs Administrator mismatch when running the commands.
The command is executed in silent mode, so you will not be able to see any progress signs etc. If there are any issues when running the commands then you can check EventViewer for the details.  

We can avoid all this pain if we are careful when installing SQL Server though :).