Particularly, in Versus 2008, I wish to connect with an information source that you could have by right-hitting the instantly-produced Application_Data folder (an .mdf "database"). Appears easy, which is knowing how.

I simply determined how to get this done. I'll publish my answer below, that will range from the one factor no tutorial on MSDN incorporated that unexpectedly happens to be essential, that is, let's say there's no Data menu?.

An excellent resource I usually keep around is It is handy for locating these connection strings whenever you aren't able to find a good example.

Particularly this page put on your condition

Fasten a database file on connect with a nearby SQL Server Express instance

Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

So here's the solution from MSDN:

Choos[e] "Add New DatabasesInch in the Data menu.[And stick to the connection wizard]

Super easy, with the exception that I've no Data menu. Without having an information menu, perform the following:

  • Click Tools >> Connect with Database...
  • Choose "Microsoft SQL Server Database File", go ahead and take default Data provider, and click on OK
  • Around the next screen, browse for your Database file, which is inside your Versus Solution folder structure somewhere.

Test the bond. It will be good. If you wish to add the string to the net.config, click on the Advanced button, and copy the information Source line (at the end from the dialog box), and paste it right into a connection string within the appropriate devote the net.config file. You'll have to add the "AttachDbFilename" attribute and cost. Example:

The raw text in the Advanced panel:

Data Source=.\SQLEXPRESS;Integrated Security=True;Connect Timeout=30;User Instance=True

The particular entry within the web.config:

<add name="SomeDataBase" connectionString="Data Source=.\SQLEXPRESS; 
Integrated Security=True; Connect Timeout=30; User Instance=True" />

I think you'll found this helpful. If any thing about this is confounding you, leave a comment and I'll expand onto it.

Only one more -- i have always stored a udl file on my small desktop to simply create and test connection strings. If you have never tried it before - produce a new text file and title it to connection.udl (the ext may be the only important part). Open the file, begin the Provider tab and come through. Once you are pleased with the bond relabel the file passing on b .txt extension. Open the file and copy the string - it's relatively simple and allows you test the bond before utilizing it.

<add name="Your Database" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Expanse.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>