sql-serverdatabasemdf

Cannot access localDb in Visual Studio after copied DB from another project


Problem statement

I have copied my local database (.mdf file) from one project into another. When I try to connect to the copied local database, it says it does not exist and it doesn't even show the database name.


Some background

I have made an ASP.NET and ADO.NET app in my previous project. And now, I need that same database that was used (with the data intact and all) in the previous project to be in a WCF project, which is another project.


Images of the problem

Image 1: Setup

enter image description here

Image 2: The error (when I click on "Test Connection")

enter image description here


As you can see, the database does exist in my current project (first image) but Visual Studio does not find it. What is wrong here?


Solution

  • I found that my folder, where my project and solution are located where for some reason placed in the wrong directory.

    With that said, I couldn't find the .mdf file to connect to because I was looking at the wrong area of my computer. Now that I moved my folder to the correct location, I was able to access the .mdf file and connect to it.

    This solved my issue.