.NET Framework 4 now supports LocalDB!

Updated 2011-11-11: Added a link to the post on how LocalDB handles database file locations.

Updated 2012-01-03: Clarified that only SSMS from SQL Server 2012 (or newer) will work with the .NET 4 Update 4.0.2, since earlier SSMS versions are using .NET 3.5.

.NET Framework 4 Update 4.0.2

.NET team has just released Update 4.0.2 for .NET Framework 4. This update enables connecting to SQL Server Express LocalDB via System.Data.SqlClient provider.

.NET Framework 4 Update 4.0.2 can be downloaded from http://support.microsoft.com/kb/2544514

Does this work?

Well, let's give it a try!

We start by installing SQL Server 2012 Management Studio RC0 (SSMS) and LocalDB together with .NET 4. The version of SSMS is important as earlier versions are using .NET 3.5 and currently only .NET 4 can be updated to understand LocalDB connection strings. Next we update .NET 4 to 4.0.2 (hey, no reboot in my case!). Then fire up SSMS. When prompted for the server address we specify "(localdb)\v11.0", like this:

Clicking Connect and … (drum roll please!) …


Does it really work?

OK, so we confirmed SSMS connects to LocalDB. Which is great, but how about doing something more useful for a developer? The next logical step would be to create a database. We know the drill -- right-click the Databases node in Object Explorer and select New Database. So far, so good. After typing in the name of the new database (in my case LocalDBTest) we are ready to hit OK...

Clicking OK and ... we hit an error!


This is obviously a bug, but there are at least two reasons we shouldn't panic. First, the bug has an easy workaround that we're going to use very, very soon. Second, it points to an important characteristic of the way LocalDB handles database files. I will explain it in more detail in the next post, but for now let's get back to LocalDB and creating our database.

To work around this problem we need to explicitly specify the folder for the database files. For the lack of a better location let's just put them into My Documents, like this:

This time clicking OK creates the database without any problems.

We are now ready for some serious database development, but this too will have to wait for another post.

- Krzysztof Kozielczyk

Send us Your Feedback

Please share your feedback with us! Feel free to start a thread on SQL Express Forum, hit the "Email Author" button on this post or file a Connect item!

Comments (12)
  1. Papy Normand says:

    Clear and useful article. Thanks for it.

    But sorry for you, i will wait for the official release of SQL Server 2012 ) to test it ( with an Express and Developer edition ).

    I am surprised because no reboot is necessary .Good news but when i will install .NET Framework 4 Update 4.0.2 , i think i will do a reboot ( as a precaution only )

  2. Krzysztof Kozielczyk - MSFT says:

    @Papy Normand:

    Thanks, I'm glad you found this post useful!

    I do expect the reboot will be necessary in many cases, after all we're updating .NET Framework here, a key component for the system. Maybe I just got lucky, I installed the update a few times and never had to reboot, or had any problems.


    Krzysztof Kozielczyk, Program Manager for SQL Server Express

  3. James William says:

    Could you please leave the link to download SSMS as well ?

  4. Krzysztof Kozielczyk - MSFT says:

    @ James William

    At this moment (January 2012), SQL Server 2012 Management Studio RC0 can be downloaded from here:


    Just select it from the drop-down list and click "Download".

    The page will probably disappear as soon as SQL Server 2012 is released, which is expected as you should use the RTM version at that time 🙂


    – Krzysztof

  5. Daniel says:


    I updated to: .NET Framework 4 Update 4.0.2 can be downloaded from support.microsoft.com/…/2544514

    and after that Visual Studio started to get painfully slow. Also I noticed a performance drop in ADO.Net communication. Problem was still there after reboot. The same code running on a computer without the update doesn't have that problem.

    Don't know if it's a coincidence but it didn't feel like it. Messed up the computer while uninstalling so I ended up in complete reinstall. And with everything in place except the update above, everything works again.


  6. Krzysztof Kozielczyk - MSFT says:


    We have not seen any other reports of ADO.NET performance problems caused by .NET Update 4.0.2. ADO.NET team is very interested in learning more about this case. If you have more details that could help us investigate further, could you please contact us directly by clicking the Email Author button?


    – Krzysztof

  7. tibor.sas@nuance.com says:

    Hi, based on what I understand the automatic start of the instance only works if you use the (localdb) … syntax in the connection string, which in turn works only if you have .NET fw 4.0.2 installed.

    What if I dont want to force the user to install it (actually I dont want to encapsulate it into my installer and I dont want to force them to perform the install from MSFT).

    As a consequence of the above I'm able to connect to the instance only via the named pipe, which is OK; but do I need to ensure that the instance is running on my own, via the LocalDB API calls? Is this available only as a native C++ library? Thanks,

    – Tibor

  8. Yes, you do need to ensure that the instance is running using the LocalDBStartInstance API call. And yes, this is currently available only as a C++ library.

  9. Jon Marozick says:

    The create database bug you describe is still present in the RTM version.

  10. Yes Jon: unfortunately, this is true for RTM. It will be fixed in Service Pack 1 for SQL Server 2012. Until then, you need to use the workaround described in the original post.

  11. Rajesh says:

    While i am running on application,at the time i got following error..

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server).what can i do.? what's the solution for that error.?

  12. Peter says:

    Referenced here from a question on stackoverflow. I am using SSMS 2008 R2 SP2 on my developer machine and i am able to connect to the localdb server using servername: (localdb)v11.0. Could there have been some update to the .Net framework 3.5 that allows the connection using this servername? I can't find any info about this using google. I Also get an error when using a non developer machine.

Comments are closed.

Skip to main content