0

I have a very simple database (just 3 tables and a dozen rows or so each) that is designed for use with an ASP.NET MVC 5 project. I am using Visual Studio 2013 Ultimate.

I want to be able to post my Visual Studio solution for others to download and learn from. These examples will often be Visual Studio ASP.NET MVC solutions that appear in my blog. I've successfully publish console-type applications but I've never published any applications that use a database.

In my current project, I'm using a connectionstring that begins with "Data Source=(localdb)\v11.0". What I don't understand is how to provide a copy of my existing database to my reader. Is it a physical file on disk? If so, where is it (it doesn't appear as a path in the ASP.NET/MVC-provided default connectionstring) and how can it be included in a downloadable Zip file for others to easily download and install? Does NuGet or GitHub somehow automate this process? For the records, I googled around and also didn't find any articles that discuss how to do this (admittedly, I used the search terms "share" and "database" and saw a lot of hits having to do with network sharing--not what I intended...).

Finally, if at all possible I want my users to be able to download the solution/project files and run the project successfully right away. I don't want them to have to go into web.config and edit connectionstring or other system/configuration/environment values.

Majid
  • 13,853
  • 15
  • 77
  • 113
Jazimov
  • 12,626
  • 9
  • 52
  • 59
  • The connection string has no information on what database I'm using but it does have a AttachDbFilename value that ends in MDF. It is the default DB engine for VS 2013, so I suppose it's SQL Express. Is there a way to avoid asking my users to restore the DB? Can I just include it in the directory tree contained in my Zip file and ensure that the VS 2013 web.config file points to a folder that's in the VS 2013 solution? – Jazimov Feb 25 '14 at 14:28

1 Answers1

0

There is no information on what type of database you are using ? i.e. (SQL SERVER / My SQL / Oracle)

Would share you on SQL Server and to share your Local Project with Database. There are two ways through which you can share Project (including database).

  1. Share the BAK file with Project - Take Backup of your project and include the same in the Project ZIP file and upload. So if any user downloads it then it will restore the BAK file (Database file) and then can connect down project with database.

  2. Share the Physical file (MDF and LDF) with Project -

(a). By default, MDF and LDF files are located in SQL Server >> MSSQL >> Data (b). Concerned database MDF file should be taken and added in ZIP file (c). Person downloading will extract the file and Use SQL Management Studio >> Database >> "Restore Files and Filegroups" option (d). Restore the database and run the project

Darshit Shah
  • 629
  • 5
  • 5
  • OK, thanks. I found MSSQL under %programfiles%\Microsoft SQL Server. I also found the MDF and LDF files there as you suggested. Zip file aside, would NuGet or some other process allow me to just share my VS 2013 solution so that users aren't bothered with having to manually copy files around or run restore processes? – Jazimov Feb 25 '14 at 14:49
  • Yes You can share the MDF files with whole project. It is better to mention the database restoration process in Text file in Project so that users can get better idea to restore it and use the project – Darshit Shah Feb 26 '14 at 00:46
  • I'm trying to be as clear as possible: I do not want the user to have to do anything--no copying, no readme, no restore, etc. I'm looking for a way to provide a Zip with my MDF so that they extract to a folder and run the application. Is there no way to do this? – Jazimov Feb 26 '14 at 02:04
  • Finally, then you have to do coding for the same so that User when Run the application automatically MDF file will copy. – Darshit Shah Feb 27 '14 at 04:29
  • I don't know that I believe that this would be necessary. Upon further consideration, wouldn't it be possible to move the MDF to a "data" folder within my MVC project and point my web.config connectionstring value to it? I will experiment... – Jazimov Feb 27 '14 at 21:41