Overview

LocalDB Companion is a very simple tool that automates common tasks for developers using LocalDB, focusing on helping them with LocalDB under IIS and ASP.NET.

The tool controls the user's Automatic LocalDB Instance. It appears as a system tray icon and offers several commands through context menu.

LocalDB Companion is also an example of using PInvoke into LocalDB API to control LocalDB instance.

Use Example

If you prefer to learn by example, see Use Example: Sharing LocalDB Instance with ASP.NET App Under IIS

Context Menu Commands

Copy Address to Clipboard

Copies the address of the Automatic Instance into Clipboard that can be pasted into Server Name field in SSMS connection window. The value depends on if the instance is shared or not and is set to (localdb)\v11.0 or (localdb)\.\AspNet4PoolId respectively.

Copy Connection String to Clipboard

Copies a connection string template into Clipboard that can be pasted into web.config or SqlConnection constructor. The value depends on if the instance is shared or not, for example: Server=(localdb)\v11.0;Integrated Security=SSPI;Database=???

Start Automatic Instance

Starts the user's Automatic Instance of LocalDB and keeps it alive until it is stopped or LocalDB Companion tool is closed (the last part is not yet implemented :-)).

Stop Automatic Instance

Stops the user's Automatic Instance of LocalDB.

Share Automatic Instance with ASP.NET

Shares the user's Automatic Instance under a public name of (localdb)\.\AspNet4PoolId. It also creates a login for ASP.NET application pool in the user's Automatic Instance. The login is granted full control over the user's Automatic Instance. The process is described in this blog post.

Because LocalDB Companion assumes the ASP.NET application is configured in the default way, which means it is running as IIS APPPOOL\ASP.NET v4.0, the login in user's LocalDB instance is created for IIS APPPOOL\ASP.NET v4.0.

Note that, because sharing LocalDB instance requires administrative rights, UAC will prompt the user to accept the elevation.

Stop sharing Automatic Instance with ASP.NET

Stops sharing of the user's Automatic Instance with ASP.NET. Also removes the login that was created for it.

About LocalDB Companion...

Guess what :-)

Close LocalDB Companion

Closes LocalDB Companion. If the user's Automatic Instance is started it will keep running until there are any open connections to the instance. By default it stops 5 minutes after the last connection is closed.

Last edited Dec 29, 2011 at 10:14 PM by kozielczyk, version 15

Comments

No comments yet.