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
3 answers

what join is caused by "and"?

I have a localDB database that includes the following tables: UserProfile, which contains: UserId UserName 1 Adam webpages_Roles, which contains: RoleID RoleName 1 user 2 admin webpages_UsersInRoles, which has two columns…
Adam R. Grey
  • 1,861
  • 17
  • 30
0
votes
1 answer

Entity Framework code first and membership tables on LocalDb

1. If I create new MVC project it has default connection string : < add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-OneVeryBad.Web-20130301153805;Integrated …
mishap
  • 8,176
  • 14
  • 61
  • 92
0
votes
1 answer

Entity Framework Code First Nullable Integer

I posted this on the entity framework developers site with no response so I'll ask here also. By default EF Code First creates "not null" entries for integers. I'd like to create nullable integer entries. I've found C# examples (this site) but…
user1626137
  • 233
  • 1
  • 3
  • 10
0
votes
0 answers

What are the pros and cons attaching TDE enabled .mdf to SqlLocalDb?

I am thinking to attach TDE-enabled .mdf files to SqlLocalDb. Before investing time in it, I want to know whether it is worth doing that? So need some helpful suggestions.
Siddharood
  • 908
  • 1
  • 12
  • 24
0
votes
2 answers

Is it possible to run an MSI from an InstallShield Express Custom Action?

I am using InstallShield Express Spring 2012 SP1. I would like to run the SQLLocalDb_x64.MSI from a custom action. Is it possible to run an MSI from a custom action in InstallShield Express?
Doug Kimzey
  • 1,019
  • 2
  • 17
  • 32
0
votes
1 answer

Hide the database schema and data in deployed Lightswitch / SQL Server 2012 LocalDb

I am creating a 2-tier Lightswitch application which will be deployed via ClickOnce for single-user scenarios. The database schema and the data need to be protected from access by the users. I know that this might not be perfectly possible, but are…
0
votes
1 answer

Entity Framework doesn't save updates to the underlying database

I am using the following code to update clock in and clock out times in the record table but it doesn't save the data to the database. I checked the mdf file with sql management studio and there is no data saved. What am I doing wrong? private void…
Mr1159pm
  • 774
  • 1
  • 10
  • 21
0
votes
1 answer

HTML5: location of local DB

I am a new bid in HTML5 please help me with this I am creating a local DB via HTML% apis on client machine like this function initDB(){ var shortName = 'stuffDB'; var version = '1.0'; var displayName = 'MyStuffDB'; var maxSize = 65536; // in…
Ankit Sachan
  • 7,690
  • 16
  • 63
  • 98
0
votes
1 answer

Disable LocalDB auto-upgrade

After connecting to a SQL Server 2008 R2 database using LocalDB (SQL Server 2012), now I cannot connect from SQL Server 2008 R2: The database 'Northwind' cannot be opened because it is version 706. This server supports version 663 and earlier. A…
Max Toro
  • 28,282
  • 11
  • 76
  • 114
0
votes
2 answers

Concurrent use of LocalDB on a network drive(s)

My configuration is as follows: Server with Z: mapped to d:\something Client with Z: mapped to \\server\ A LocalDB MDF (and the whole application) located at Z: Either computer alone is OK, but doesn't work simultaneously. I get an exception…
jrev
  • 33
  • 4
0
votes
1 answer

Why does System.Web.Security.Roles.RoleExists in combination with LocalDB source require MSDTC?

In a .NET 4.0 project, I'm experiencing that a call to System.Web.Security.Roles.RoleExists within a System.Transactions.TransactionScope fails due to MSDTC not being enabled on my development machine. The role manager's data source is LocalDB and…
aknuds1
  • 65,625
  • 67
  • 195
  • 317
0
votes
3 answers

Using SQL Server Native Client to access SQL Server LocalDB

I'm trying to connect to a SQL Server LocalDB instance using the SQL Server Native Client driver. This is because we are looking to use Native Client in our production environment to gain access to the use of subject alternative names on SSL…
Colin Bowern
  • 2,152
  • 1
  • 20
  • 35
-1
votes
1 answer

Asp.net Core API Deploying with a database on IIS

I'm trying to deploy an API on IIS. But no matter how I try to do it, I can't solve the following problem. When I try to deploy asp.net core example api there is no problem with it. When I call an endpoint there are data. If I try to deploy my api…
-1
votes
1 answer

I have access to a database in SQL Server (but not to the server that it runs on) and want to copy it into a SQL Server LocalDB

SQL Server Management Studio does not support LocalDB, so I can only use it to export the data on the server. I can export the schema via scripts and the data (but only table by table) with csv for instance. But that is lot of work. What is the best…
citykid
  • 9,916
  • 10
  • 55
  • 91
-1
votes
2 answers

How to SUM() a column and write in another column in same table

So i'm a newbie at programming and i need to store data.I have created Service-Based Database for store the data and i have a table like this. gameprice gamedesc gametotal 60 RDR2 40 R6S I want to take gameprice column, sum it, and…
user19541730