2

The problem is that the path to my database shown in the error below is incorrect. I cannot find where that path is set as it is not in the settings or in any of the project files. What am I missing:

The error:

An attempt to attach an auto-named database for file H:\FoxCityGuide\FoxCityGuide\App_Data\Restaurants.mdf failed.

The path to the database:

H:\FoxCityGuide\FoxCityGuide\Restaurants.mdf

app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections></configSections>
  <connectionStrings>
    <add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurants.csdl|res://*/Restaurants.ssdl|res://*/Restaurants.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SFP;attachdbfilename=|DataDirectory|\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>
Susan
  • 1,822
  • 8
  • 47
  • 69

1 Answers1

0

2 options here.

  1. Move your .mdf file into the App_Data folder as that is where |DataDirectory| is pointing.

  2. Update your connection string to point at the .mdf file in its current location by editing the 'attachdbfilename=' value of your config.

benni_mac_b
  • 8,803
  • 5
  • 39
  • 59