Suppose I have created a SQL Server database called Database1.mdf in the App_Data folder in Visual Studio with a table called Names. <
Database1.mdf
App_Data
Names
You try with this string connection
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|Database1.mdf;Database=dbname; Trusted_Connection=Yes;