All posts tagged 'S2012'

.NET Musings

Fixing SQL Server Express Local DB for Visual Studio

LocalDB is a (fairly) new, stripped down version of SQL Express 2012.  It doesn’t require a service, so it can be deployed much easier along with your Visual Studio project.  It’s a great alternative for applications that don’t need all of the power of SQL Server, and where you don’t have control over the target machine to ensure that SQL Express is installed.  In fact, many of the samples available from Microsoft use LocalDB. Are you using LocalDB?  It’s easy to check.  If your connection string starts with “(LocalDB)\v11.0”, indeed you are.

Sounds great, doesn’t it?  Except when LocalDB doesn’t work.  I ran into this issue on my main development machine.  I tried reinstalling LocalDB (there is a separate install on the SQL Server Express download page), uninstalled SQL Express and reinstalled, you know, all of the usual tricks.  No luck.

After much searching on the interwebs, I found this TechNet forum post: which pointed to this TechNet article:

To sum it up, open a command window (preferably running as administrator), and navigate to where the LocalDB general instances are kept (%localappdata%\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0), and type:

>sqllocaldb create "v11.0"

If you receive an error similar to this:

"Creation of LocalDB instance "v11.0" with version 11.0 failed because of the following error:
LocalDB instance is corrupted. See the Windows Application event log for event details."

Your LocalDb needs to be deleted and re-created.  Fortunately, it’s easy. Enter these commands:

>sqllocaldb delete "v11.0"
Response whould be similar to “LocalDB instance "v11.0" deleted. \”

Once you’ve cleaned out the corrupted instance, re-create it:

>sqllocaldb create "v11.0"
LocalDB instance "v11.0" created with version 11.0

And that’s it!  You should be able to fully take advantage of LocalDb in your projects now.

About the author

Philip Japikse

Philip Japikse Philip Japikse is an international speaker, a Microsoft MVP, INETA Community Champion, MCSD, CSM/ CSP, and a passionate member of the developer community, Phil has been working with .Net since the first betas, developing software for over 20 years, and heavily involved in the agile community since 2005. Phil works as a Principal Developer Advocate for Telerik. Phil co-hosts the Hallway Conversations podcast (, and is the Lead Director for the Cincinnati .Net User’s Group ( You can follow Phil on twitter via read his Telerik blog at and his personal blog at
Managed Windows Shared Hosting by OrcsWeb