Visual Studio 2015 and LocalDB instance for LightSwitch

Purpose

With Visual Studio 2015 RTM the database tooling has changed. How LightSwitch uses LocalDB has changed too. Remember the issue with VS2013 and LightSwitch SQL Server Project references being blank? Let us take a look and see what changed in this area and determine if LightSwitch and SQL Database Projects work better together.

Background

How and why have things changed with LocalDB? I will refer to this Microsoft Connect feedback from 2014:

SQL Server 2014 Express LocalDB does not create automatic instance v12.0

In SQL14, we moved away from the numbering/versioning for the automatic instance and named itMSSQLLocalDBinstead of “v12.0”. The name of the automatic instance in the SQL14 documentation for LocalDB at http://msdn.microsoft.com/en-us/library/hh510202(v=sql.120).aspx has been fixed. If you require an instance to be named “v12.0”, you can create a named instance with that name.
Thanks & Regards, Pooja Harjani, Sr. Program Manager, SQL Server, Microsoft.”

A SQL 2014’s Local DB sample connection string looks like this:

Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\mydb.mdf;Initial Catalog=mydb;Integrated Security=True;MultipleActiveResultSets=True

How this surfaces in LightSwitch

So, the name for the automatic instance is MSSQLLocalDB. This is the instance that LightSwitch in Visual Studio 2015 now uses to create intrinsic databases for projects.

Here is a screenshot of the SQL Server Object Explorer window in VS2015 showing two intrinsic databases underlying LightSwitch projects:

LightSwitch LocalDB use in Visual Studio 2015

LightSwitch LocalDB use in Visual Studio 2015

The ‘UserVoice‘ test project was created using VS2015 RC and is uppercase. The LightSwitch test project ‘ResearchDatabaseApp‘ was created using VS2015 RTM. This is where we can find our development time intrinsic databases.

Refer to SQL Server Data Tools RTM update for July 2015 blog post for final details with respect to Visual Studio 2015 RTM.

LightSwitch and SQL Database Projects

Next, I created a new SQL Database Project called ‘ResearchDatabase‘ in the same solution as the LightSwitch ‘ResearchDatabaseApp‘ project. Here is a screenshot showing the default target platform as SQL Server 2014.

LightSwitch-ResearchDatabase-project

Then moving to the LightSwitch project properties straight away we see:

LightSwitch SQL Database Project reference working in Visual Studio 2015

LightSwitch SQL Database Project reference working in Visual Studio 2015

The new project shows up immediately in the LightSwitch project properties. You can write scripts to manage the intrinsic database whenever you build or deploy the LightSwitch application. With post-deployment scripts, you can populate data, enhance the schema or add an index. Refer to the MSDN LightSwitch documentation for details: Managing the Intrinsic Database for LightSwitch.

Summary

So with Visual Studio 2015 and new LightSwitch projects the linking to SQL Database Projects is back working as it should! Another sign of continuing maintenance support for LightSwitch.

Advertisement

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 )

Connecting to %s