Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top