I use localdb in my wpf project app which use entity framework code first. When application running in first time local db database files are created to 'C:\Users\CurrentUserName' path as default. How to change this default path to another location which user selected.
My connection string
<connectionStrings>
<add name="L10CompanyContext" connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=L10Company;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
Its as easy as this
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\path\to\Database.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database.
Use the SqlLocalDB utility to create an instance of Microsoft SQL Server 2016 ExpressLocalDB. The SqlLocalDB utility (SqlLocalDB.exe) is a simple command line tool to enable users and developers to create and manage an instance of SQL Server ExpressLocalDB. For information about how to use LocalDB
Syntax
SqlLocalDB.exe
{
[ create | c ] \<instance-name> \<instance-version> [-s ]
| [ delete | d ] \<instance-name>
| [ start | s ] \<instance-name>
| [ stop | p ] \<instance-name> [ -i ] [ -k ]
| [ share | h ] [" <user_SID> " | " <user_account> " ] " \<private-name> " " \<shared-name> "
| [ unshare | u ] " \<shared-name> "
| [ info | i ] \<instance-name>
| [ versions | v ]
| [ trace | t ] [ on | off ]
| [ help | -? ]
}
The following example creates an instance of SQL Server ExpressLocalDB named DEPARTMENT using the SQL Server 2017 binaries and starts the instance.
SqlLocalDB.exe create "DEPARTMENT" 12.0 -s