To utilize the associated database connection string in Web.config. The mdf database will not operate.

asp.net entity-framework sql-server sql-server-2008 visual-studio

Question

The file neodb.mdf is located in my App Data folder, and I can access the database using built-in SQLEXPRESS in Visual Studio's server explorer:

Currently trying in vain

 <connectionStrings>
    <add name="EFDbContext" connectionString=".\SQLExpress;AttachDbFilename=|DataDirectory|neodb.mdf; Database=neodb;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

and

 <connectionStrings>
    <add name="EFDbContext" connectionString="Data Source=.SQLEXPRESS;Database=neodb.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

As far as I'm aware, the *.mdf file type is a SQL server database file type, and the owner of the file when it's added to the initial catalog is.dbo. What is the first catalog available anywhere?

1
10
10/7/2011 1:26:53 PM

Accepted Answer

This format works if the *.mdf file is located in the App Data folder:

<connectionStrings>
  <add name="ConnectionName"
    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|DatabaseName.mdf;Integrated Security=True;User Instance=True"
    providerName="System.Data.SqlClient" />
</connectionStrings>
14
10/7/2011 1:41:11 PM

Popular Answer

The connection string for each database may be obtained in a straightforward manner. In Solution Explorer, double-click the "DataBase.mdf" file. In Server Explorer, right-click the "DataBase.mdf" file and choose "Properties." The connection string is now visible in the properties menu (under the "Connection" heading)!



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow