LocalDB on Visual Studio 2010

1 minute read

So I’ve been starting to play with LINQ to get ready to start using the Entity Framework (I am hoping to start using it for projects at work as I want to move away from Access Databases).  Anyway, I found out about LocalDB which allows you to use a MS-SQL database without actually installing the SQL engine.  The neat thing about this is that you get to use the full features of MS-SQL databases without any limitations.  Check out more about LocalDB here. Anyhow, I  am going to start using this on both my development machine at work, my main workstation at home and my laptop.  Below are the steps I took to configure this for future reference:

  1. Make sure you have Visual Studio 2010, Service Pack 1.
  2. Download Update 4.0.2 for the .NET Framework 4.0 and install it on the workstation/laptop.
  3. Download the SqlLocalDB.msi file (x86 or x64 depending on your machine)
  4. After installing the SqlLocalDB.msi file open up Visual Studio 2010 and add a new connection
  5. Use the default SQL Client and for database use: (localdb)\v11.0
  6. Attach the database you want to open up, test connection and if all goes well, you should get a successful connection.
There is going to be one more change that you’ll need to make in the connection string in the app.config (or web.config for asp.net projects).  The connection string should look like this:
<connectionStrings>
 <add name="DB_Name"
 connectionString="Data Source=(localdb)\v11.0;
                   AttachDbFilename=[Path_To_DB]\DB_Name.mdf;
                   Initial Catalog=DB_Name;Integrated Security=True"
 providerName="System.Data.SqlClient" />
</connectionStrings>

Note: For more information on setting this up on a workstation, check out this article on msdn.

Updated:

Leave a comment