Difference between (localdb)\v11.0 and .\sqlexpress in connection string
SQL Server Express is a service-based version of SQL Server i.e. it runs as a service all the time, independently of other applications. When you say .\SQLEXPRESS
you are looking for a named instance of SQL Server called SQLEXPRESS
that is on your local machine and connected to via a shared memory interface (that's what the dot is).
Local DB is a deployment option for SQL Server Express that runs as an attached process to another application, instead of as a service. It can also be started and stopped by the local db utility. Mostly it's used attached to applications like Visual Studio that just need to use a SQL Server for a while during development, but don't need it running all the time. When you connect to (localdb)\v11.0
you are connecting to one of these attached instances, and in this case using version 11 (you can have multiple versions of localdb on the same machine).
How to connect to LocalDb
I think you hit the same issue as discussed in this post. You forgot to escape your \
character.
How to connect to LocalDB in Visual Studio Server Explorer?
OK, answering to my own question.
Steps to connect LocalDB to Visual Studio Server Explorer
- Open command prompt
- Run
SqlLocalDB.exe start v11.0
- Run
SqlLocalDB.exe info v11.0
- Copy the Instance pipe name that starts with np:\...
- In Visual Studio select TOOLS > Connect to Database...
- For Server Name enter
(localdb)\v11.0
. If it didn't work, use the Instance pipe name that you copied earlier. You can also use this to connect with SQL Management Studio. - Select the database on next dropdown list
- Click OK
SQL Server (localdb)\v11.0 explained
LocalDB was introduced in SQL Server 2012 CTP3. It’s basically a new version of SQL Express, with same functionality, dedicated to developers. So you don’t need to install any SQL server. If you have installed SQL 2012 or Visual Studio 11 then you already have it, and it runs over .Net 4 or higher. If you are using Visual Studio 11 and have been playing with the new EntityFramework and MVC, you can see it on the default connection string.
MDF is the default extension for SQL Server database files. (Log files are LDF) Also see this question.
You can restore to a specific folder by using
RESTORE DATABASE WITH MOVE
as documented on MSDN here.LocalDB is intended for developers, see point 1.
The SQL Server Express blog has an informative post about LocalDB here.
Creating a Connection String and Working with SQL Server LocalDB
The initial Catalog is missing in MovieDBContext
connection string.
It needs to be as follows:
<add name="MovieDBContext" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Movies.mdf;Initial Catalog=Movies;Integrated Security=True" providerName="System.Data.SqlClient"/>
Related Topics
What Are Major Differences Between C# and Java
Difference Between Namespace in C# and Package in Java
Does Java Have Something Similar to C# Properties
How to Read a .Net Guid into a Java Uuid
What Is the "Volatile" Keyword Used For
How to Lock a Table on Read, Using Entity Framework
How to Use the Cancellationtoken Property
How to Get Ascii Value of String in C#
Order of Serialized Fields Using JSON.Net
Closing Excel Application Process in C# After Data Access
What Setup Code Should Go in Form Constructors Versus Form Load Event
Webexception How to Get Whole Response with a Body
Add "Everyone" Privilege to Folder Using C#.Net
Are Static Methods Thread Safe
Mutating the Expression Tree of a Predicate to Target Another Type
Format Number Like Stack Overflow (Rounded to Thousands with K Suffix)
How to Implement Generic Repository Design Pattern with Dapper