Questions tagged [localdb]

LocalDB is a lightweight deployment option for SQL Server Express Edition with the same features but with a simple installation. To support scenarios where multiple users of the computer need to connect to a single instance of LocalDB, LocalDB supports instance sharing but does not support sharing among multiple computers.

SQL Server Express LocalDB, introduced in SQL Server 2012, is a light-weight version of SQL Server Express that replaces User Instances, which were introduced in SQL Server 2005. LocalDB (as it is commonly referred to) instances are created per user, and the instance and their databases are by default installed into a user's local profile directory. (It's possible to save the database file elsewhere, including on a server share). By default these instance are private, but they can be shared with other users on the same computer.

LocalDB runs as a background process for each user that starts their own private instance rather than as a service that is shared by all users and would have its own security context. Connectivity is only through Named Pipes; external connectivity is not available. However, specifying the correct named pipe to connect to can be problematic due to the instance name changing each time it starts (i.e. instance name = LOCALDB#{8_character_alphanumeric_id}, named pipe = np:\\.\pipe\LOCALDB#{8_character_alphanumeric_id}\tsql\query).

Fortunately, a new special syntax for the Server Name was added to use in connection strings. You can specify (localdb)\InstanceName in SSMS, SQLCMD, and via the SqlConnection class in .NET applications (though be aware that this was not available until .NET Framework version 4.0.2). This syntax provides two benefits:

  1. It allows for using a consistent server name in your code
  2. It will automatically start the LocalDB instance if it is not already running.

LocalDB can be started, stopped, and otherwise managed via the SQLLocalDB.exe utility. Additionally, LocalDB will be automatically started when using the (LocalDB)\InstanceName connection string syntax, and it will automatically stop about 5 minutes after the last connection closes.

The easiest way to use LocalDB is to connect to the automatic instance owned by the current user by using the connection string "Server=(localdb)\MSSQLLocalDB;Integrated Security=true". To connect to a specific database by using the file name, connect using a connection string similar to "Server=(LocalDB)\MSSQLLocalDB; Integrated Security=true ;AttachDbFileName=D:\Data\MyDB1.mdf".

To connect to a shared instance of LocalDB add .\ (dot + backslash) to the connection string to reference the namespace reserved for shared instances. For example, to connect to a shared instance of LocalDB named AppData use a connection string such as (localdb)\.\AppData as part of the connection string. A user connecting to a shared instance of LocalDB that they do not own must have a Windows Authentication or SQL Server Authentication login.

For more info, please see:

1023 questions
0
votes
1 answer

Added rows in localDB disappear after closing Visual Studio or cannot be queried?

So I have a database filled with values already. It works fine, until I start to query any values I have added into it. It just won't work. I'm using a project on Visual Studio creating a Web Form, while the database connection, as well as the add,…
yaserso
  • 2,638
  • 5
  • 41
  • 73
0
votes
1 answer

Convert MySql Database to C# LocalDB

Is there any way that can convert or transfer a MySql Server Based Database to LocalDB in C#? Actually, my application connects to MySql Server Based Database through Localhost. (i made the database in MySql Workbench 5.2 CE) What i want is to take…
0
votes
1 answer

ConnectionStrings Current Language=Portuguese not working with (LocalDB)\v11.0

I use this connection string with SQLExpress and I can get the error messages in portuguese.
ramaral
  • 6,149
  • 4
  • 34
  • 57
0
votes
1 answer

Windows Phone LocalDB Method has no supported translation to SQL

I want compare datetime (i need parse it) with now in LINQ query From i In db.Downloads Where i.WantExpiration And DateTime.Parse(i.Expiration) < DateTime.Now Everytime i get error: Method 'System.DateTime Parse(System.String)' has no supported…
Misaz
  • 3,694
  • 2
  • 26
  • 42
0
votes
1 answer

When converting data type datetime overflow occurred

i am working with localDB on Windows Phone and i want to work with datetime. Everytime i get error An exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.Linq.ni.dll but was not handled in user code in inner exception…
Misaz
  • 3,694
  • 2
  • 26
  • 42
0
votes
1 answer

Database corruption

I am planning to use localdb for next project and thinking of making rotating backup of database (it will be detached normally and only attached when software is running). And I was thinking how to do automatic restore from backup. This required me…
Sinatr
  • 20,892
  • 15
  • 90
  • 319
0
votes
1 answer

Error when opening app on different computer

I have just finished an app that is using a database.mdf. Everything is working well, but when I open the app on a different computer, I'm getting the following error: "A network-related or instance-specific error occurred while establishing a…
user2851021
  • 71
  • 1
  • 9
0
votes
1 answer

Can't generate scripts from LocalDB in SQL Management Studio

I can't export scripts from my LocalDB database (localdb)\v11.0. (SQL Express is fine) The error I get is Save or Publish Scripts Report Getting the list of objects from 'XXX'. Failed System.IndexOutOfRangeException: Index was outside the…
Tom
  • 12,591
  • 13
  • 72
  • 112
0
votes
2 answers

My database is not working when I deploy MVC 5 application to Windows Azure

I have built a MVC-5 application in Visual Studio Express for Web 2013. I am using localdb which contains a few tables. I am using code first migrations and I have set up a seed method. When I run the application locally it runs perfectly but my…
Paulie22
  • 111
  • 1
  • 1
  • 9
0
votes
1 answer

Connect to LocalDB from installer class

I'm trying to install database to LocalDB from installer class. When trying to open SQLConnection, I get an error: Login failed for user 'NT AUTHORITY\SYSTEM' It seems that the installer class runs from the system account, and LocalDB cannot be…
Aleksey Shubin
  • 1,960
  • 2
  • 20
  • 39
0
votes
1 answer

How to use localDb with entity framework migrations?

I have Persistence class library, which contains my DbContext class. It also contains app.config file, where I have predefined connection string like this:
0
votes
1 answer

Duplicate a tables structure

Ive got a localDB in VS2013, and I need to copy/clone the structure of a table and make a duplicate of it. How do I do this? My Google skills are failing me. P.s. The existing table is called manufaturers and I want the cloned version to be called…
Phill Healey
  • 3,084
  • 2
  • 33
  • 67
0
votes
0 answers

vs 2013 mvc localdb - no access to option

I have a problem with localdb. When I open context menu I see only Refresh, Copy and Properties. I can't open a table, why?
user140503
  • 127
  • 1
  • 8
0
votes
1 answer

SQL localdb problems with ADO

I have a native c++ application which uses ado connections to access a SQL Server Express database. For the demo purpose am planning to use LocalDB. But I read that localdb doesn't support ado connections. Is this true??
user1687824
  • 807
  • 2
  • 10
  • 24
0
votes
1 answer

In Visual Studio 2013, how do I work on a local database and then deploy only the changes to Azure?

I am doing development in VS 2013 against local instances of SQL Server - both an actual SQL Server instance and also a localDB. Is there a way I can deploy changes (schema and data) I make locally to an Azure instance of that database?
Robert
  • 353
  • 3
  • 14