2

Recently, I'm practicing the DB and trying to apply it to my project.

However, I am little bit confusing of changing default path of new DB. Some of colleague say that I can create DB then move it to the right place. Yet, I believe there is a much simple and direct way.

BTW, the default path is "C:\Users\|myname|"

I've tried to change the default value in "SQL Server Object Explore" but it didn't work. I've tried to add "attachdbfilename=|path|" as well, yet it failed either.

I know it is a really stupid question, but I really want to know the normal or regular way to set default path when creating new DB.

PS: The connection string I use now is

"`data source=(LocalDb)\MSSQLLocalDB;
initial catalog=ProjectDatabase.SpecificDatabase.ProjectDatabase;
integrated security=True;
MultipleActiveResultSets=True;
App=EntityFramework`"
Jass Huang
  • 51
  • 2
  • Are you using .net core or .net FrameWork? You can provide path in connection string. The connection string should be in config that depends on what framework you are using. – Павел Марченко Jun 14 '18 at 08:35
  • Yes, I am using .net framework and I've already checked connection string which doesn't show the relative info. As I said, I've tried to add "attachdbfilename=|path|" into connection string. As a result, I worked as DB is existed and not work as I want to create new DB. I am not sure is there any other way to assign the path? – Jass Huang Jun 15 '18 at 02:12
  • read this article https://stackoverflow.com/questions/1833640/connection-string-with-relative-path-to-the-database-file it may help – Павел Марченко Jun 15 '18 at 10:21
  • Thanks a lot! I finally found that we can not set default path since MS doesn't allow to. Well, here's the reference:https://blogs.msdn.microsoft.com/sqlexpress/2011/10/28/localdb-where-is-my-database/ – Jass Huang Jun 20 '18 at 06:33

0 Answers0