views:

52

answers:

1

Hello folks, I've been working on an ASP.NET application accessing a DB in my local machine. Now I want to have this DB in the app's AppData folder instead, so I can easily work on it from within VS SQL instance accessing the mdf file, and easily copy and share it between programmers.

Thanks a lot!

+2  A: 

First, use SSMS to detach your database.

Next, find the MDF and LDF files for your database. They should be in:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

Copy those files to your App_Data folder.

If you want to switch to using SQL Express, then change your connection string to point to the MDF file. If you want to continue using SQL Developer / etc, then use SSMS to re-attach the MDF and LDF from their new location.

I guess I should add that this usually isn't a good idea, but I assume you have your reasons.

RickNZ
+1 for the "usually not a good idea" too...
kdmurray
I know it's a bad idea, but when you have a small simple database you want to email in 1 zip file in your project that the other developer doesn't have to execute scripts and "hey, where do i download smss?" etc. etc. that's the the best idea, is this unusual, i can live with it...
Shimmy
+1 for the good and detailed answer.
Shimmy