Thursday, February 18, 2016

Local DB from SQL Server Command Line Create with EF Conn Strings


Command
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\windows\system32>SqlLocalDb info
Projects
v11.0

C:\windows\system32>SqlLocalDb create "MyInstance"
LocalDB instance "MyInstance" created with version 11.0.

C:\windows\system32>SqlLocalDb start "MyInstance"
LocalDB instance "MyInstance" started.

C:\windows\system32>SqlLocalDb info "MyInstance"
Name:               MyInstance
Version:            11.0.2100.60
Shared name:
Owner:              DoyleJWin7\DoyleJ
Auto-create:        No
State:              Running
Last start time:    2/18/2016 2:57:13 AM
Instance pipe name: np:\\.\pipe\LOCALDB#DCDDFF50\tsql\query

C:\windows\system32>

Attach
<add name="NORTHWNDConnectionString" connectionString="Data Source=(LocalDb)\MyInstance;Initial Catalog=NorthWind;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True"
   providerName="System.Data.SqlClient" />

Use:

<connectionStrings>
  <add name="constring" connectionString="Data Source=(LocalDb)\MyInstance;Initial Catalog=NorthWind;integrated security=true"/>
</connectionStrings>

No comments:

Post a Comment