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: http://social.technet.microsoft.com/Forums/sqlserver/en-US/8bcb5f1e-0240-4df3-8a5e-7e3e73e1c45b/cant-connect-to-localdb?forum=sqlexpress which pointed to this TechNet article: http://social.technet.microsoft.com/wiki/contents/articles/4609.troubleshoot-sql-server-2012-express-localdb.aspx
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
142a3a2d-63ce-4b36-ae1e-d0ce8c1ecef2|3|5.0|27604f05-86ad-47ef-9e05-950bb762570c