0

I've created a small ASP.NET MVC application and used a SQL Server database. I saw that the database was not moved to the Solution folder, so if understood correctly, the application won't work on other computers/servers.

Is it possible to move somehow the database to the project without losing the connection with the application?

Please help! Thanks in advance!

Answer:

The problem was solved with the solution from

https://www.codeproject.com/Questions/441590/How-to-add-existing-database-in-app-data-folder-in

8
  • Is this a "localdb" database? We need a bit more detail. Normally localdb is only used for development, for live use you'd want to deploy the database to an instance of SQL Server. Commented May 29, 2020 at 13:05
  • Normallly, you install your database on a server, and the users connect to it. Unless you want that every single user connect on it's own local copy of a databse? You still gonna need to install a instance of Sql server; you could use SQL express in that case ? Commented May 29, 2020 at 13:05
  • 1
    Ok so if you mean you want the database code to be in the repo, then you need you generate the "CREATE" SQL scripts which would be used to set up the database. SQL Management Studio can help you do this. Anyone in posession of those scripts would be able to generate a new database with the same design inside their own instance of SQL Server. The database is not part of your ASP.NET application, it's a separate service, so it isn't part of your .NET project. Commented May 29, 2020 at 14:29
  • 1
    What you can do to make this process easier is use a Database Project in Visual Studio (which you can add to your Solution alongside the MVC project), which can hold SQL scripts, and interact with database to generate and deploy the scripts. And then these scripts can be source-controlled in your git repository. See c-sharpcorner.com/article/… and visualstudio.microsoft.com/vs/features/ssdt Commented May 29, 2020 at 14:31
  • 1
    FYI Please don't mark questions as "Solved". That's not how this site works, it's not a forum. If you have a solution, please add it as an Answer in the section below. Answering your own questions is allowed and encouraged. That way, people can upvote your solution and also, questions with accepted or populate answers will show higher in search results when people search for similar things. I've rolled back your "Solved" edit so you can go ahead and write an answer instead. Thanks. Commented May 29, 2020 at 16:02

1 Answer 1

2

No. Seriously. ANY serious setup will have a database server and somone will apply a backup of the database you provide there. Unless you write toy applications, you NEVER employ the databsae on the same machine and "in the folder" - this works for development, it is not how SQL is deployed in the real world of larger controlled applications.

And get used on how to make upgrades to that database via some sort of change script mechanism.

Sign up to request clarification or add additional context in comments.

Comments

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.