Welcome to 2021. So now it is pretty similar to what @dean described three years ago. You can't change the default in a regular way mentioned in the article View or Change the Default Locations for Data and Log Files, by using SSMS, Object Explorer, then selecting your SQLLocalDB instance and changing its properties on the Database Settings tab.
The best answer on "why?" which I found comes from the same source:
An instance of SQL Server Express LocalDB is an instance created by a user for their use. Any user on the computer can create a database using an instance of LocalDB, store files under their user profile, and run the process under their credentials. By default, access to the instance of LocalDB is limited to its owner.
BTW, maybe you know this, maybe not: you can fill the form and then look for the Script button at the top of the Server Properties dialog window. Then if you select Script Action to New Query Window from the dropdown menu list, you can see something like this (in a new query window):
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', REG_SZ, N'C:\Data'
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'C:\Data'
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'C:\Data'
GO
Unfortunately, it probably works only for "true" SQL Server, not SQL Local DB. When I tried to use it as an administrator, I saw this:
Msg 22002, Level 16, State 1, Line 2
RegCreateKeyEx() returned error 5, 'Access is denied.'
Msg 22002, Level 16, State 1, Line 4
RegCreateKeyEx() returned error 5, 'Access is denied.'
Msg 22002, Level 16, State 1, Line 6
RegCreateKeyEx() returned error 5, 'Access is denied.'
So there is one tip, especially if you are using .NET Core/5 and try to easily use Entity Framework migrations, and Code First approach to development. You can update appsettings.json file with the connection string defining your preferred default location in the field AttachDbFileName.
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=ContactManager;Trusted_Connection=True;MultipleActiveResultSets=true;AttachDbFileName=C:\\Data\\ContactManager.mdf;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}