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`"
4
  • 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. Commented Jun 14, 2018 at 8: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? Commented Jun 15, 2018 at 2:12
  • read this article stackoverflow.com/questions/1833640/… it may help Commented Jun 15, 2018 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:blogs.msdn.microsoft.com/sqlexpress/2011/10/28/… Commented Jun 20, 2018 at 6:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.