[# VS2010] On LightSwitch and how works internally with their databases



Since a couple of days ago I I am giving a bath of Visual Studio LightSwitch. He may like you or not, but to get you out of a tight spot in a fast CRUD generation, as it is quite powerful. However, when you have a computer with more product trial versions that stable versions, you usually find yourself with errors such as the following.

The first thing I found was at the time of launch my LightSwitch application an error related to the version of SQL Server.

   1: Error    67    Sql Server version not supported.
   2: 11.00.1440    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets

Of course, the express version of Denali I have installed doesn’t like to LightSwitch. So I decided to change it from Visual Studio configuration: "Tools / / Options"and then in the section"Database Tools / / DataConnections". In my case the option that appeared was ". SQLExpress" and that version of SQL is the 11.


I changed the value for a 10 version of SQL Express that I have installed in local, but also ran the application. The next thing was to go see the execution target. That had the target path in

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets)

Because we see that it has the same code inside. I found several things, but what most caught my attention was that always used a property


that it was not declared anywhere.

   1: <!--The Development Database is built in the same location - Bin\Data - for all configurations.-->
   2: <BuildSchema Inputs="@(LightSwitchModel)"
   3:              ProjectPath="$(MSBuildProjectFullPath)"
   4:              OutputDirectory="Bin\Data"
   5:              SqlExpressInstanceName="$(SqlExpressInstanceName)"
   6:              ExternalDataSources="@(ServerExternalDataSources)"/>
   7: <!--The _IntrinsicData connection string should be updated to use the SQL Express Instance Name
   8:     from the LightSwitch Project' Property-->
   9: <UpdateDataSourceSection ConfigFile="$(OutDir)\web.config"
  10:                          Name="_IntrinsicData"
  11:                          Key="Data Source"
  12:                          Value=".\$(SqlExpressInstanceName)"/>

So the next thing was to edit the project of LightSwitch. This value is not configurable through any site, unless you edit the project *.lsproj file and in it you can see something similar to the following:

   1: <PropertyGroup>
   2:   <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
   3:   <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
   4:   <SchemaVersion>2.0</SchemaVersion>
   5:   <ProjectGuid>c3800149-599b-4dbc-ba07-190956453c17</ProjectGuid>
   6:   <OutputType>WinEXE</OutputType>
   7:   <CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
   8:   <RootNamespace>Application5</RootNamespace>
   9:   <AssemblyName>Microsoft.LightSwitch.Server.Host</AssemblyName>
  10:   <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  11:   <LightSwitchVersion>v1.0</LightSwitchVersion>
  12:   <LightSwitchProjectVersion>v1.0</LightSwitchProjectVersion>
  13:   <Name>Application5</Name>
  14:   <LightSwitchProjectType>LightSwitch</LightSwitchProjectType>
  15:   <GenerateManifests>true</GenerateManifests>
  16:   <SignManifests>false</SignManifests>
  17:   <BaseIntermediateOutputPath>bin</BaseIntermediateOutputPath>
  18:   <ApplicationClientType>Desktop</ApplicationClientType>
  19:   <ApplicationServerType>LocalHost</ApplicationServerType>
  20:   <RequireSecureConnection>true</RequireSecureConnection>
  21:   <AuthenticationType>None</AuthenticationType>
  22:   <ApplicationName>Application5</ApplicationName>
  23:   <AssemblyVersion></AssemblyVersion>
  24:   <ServiceDefinitionFile>ServiceDefinition.csdef</ServiceDefinitionFile>
  25:   <ServiceConfigurationFile>ServiceConfiguration.cscfg</ServiceConfigurationFile>
  26:   <SqlExpressInstanceName>.\sqlexpress</SqlExpressInstanceName>
  27: </PropertyGroup>

In my case, I changed the line 26 by the correct value, did a reload of the project and everything worked. But before going a couple of data to take into account

  • When you create a project of LightSwitch always take the value configured in Visual Studio. If you change the settings in Visual Studio, this change is not reflected in the draft.
  • Both Visual Studio LightSwitch tiempre working with a local sql. And this seems a very simple detail makes the name of the instance in the format ". \INSTANCIA" is invalid. Should be only the name of the instance "Instance"

Good to go with the mega project Risa

Greetings @ Here

The Bruno


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s