问题:
c:/inetpub/wwwroot/Demo/App_Data/aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
附加自动命名的数据库,但失败。已存在同名的数据库,或指定的文件无法打开或位于 UNC 共享目录中。”
解决方案:
Point 1:
Make sure U have Database.mdf file under app_data directory if you are using |DataDirectory| in the Connection String.
Point 2:
string connstring = @"Data Source=./SQLEXPRESS;AttachDbFilename=|DataDirectory|/Database.mdf;Integrated Security=True;User Instance=True";