I use :
connectionString="metadata=res://*/DomainModel.csdl|res://*/DomainModel.ssdl|res://*/DomainModel.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=.\SQLEXPRESS;
AttachDBFileName=|DataDirectory|MyDatabase.mdf;
Database=MyDatabase;
Trusted_Connection=True;
Integrated Security=SSPI;
User Instance=True;
multipleactiveresultsets=True;
App=EntityFramework""
providerName="System.Data.EntityClient"/>
The database .mdf
is in the same folder with the app .EXE and the application works fine.
But when I change the connection string to:
connectionString="metadata=res://*/DomainModel.csdl|res://*/DomainModel.ssdl|res://*/DomainModel.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=.\SQLEXPRESS;
AttachDBFileName=|%appdata%|MyDatabase.mdf;
Database=MyDatabase;
Trusted_Connection=True;
Integrated Security=SSPI;
User Instance=True;
multipleactiveresultsets=True;
App=EntityFramework""
providerName="System.Data.EntityClient"/>
and pasted the .mdf
to %appdata%
folder, my app can't connect to the database.
Is there anything wrong with the connection string?