Reputation: 339
I'm new to asp.net mvc 4
Below is my connection string
<add name="MovieDBContext"
connectionString="Data Source=(LocalDB)\v11.0;
Initial Catalog=Movies;
AttachDbFilename=|DataDirectory|\Movies.mdf;
Integrated Security=True"
providerName="System.Data.SqlClient" />
I'm getting following error when trying to access a particular control by url
Invalid value for key 'attachdbfilename'.
The error itself says it is due to a wrong connection string,but I cant find where the problem is. I'm using VisualStudio Management Studio.
Upvotes: 4
Views: 11690
Reputation: 5632
Try changing your connection string to:
<add name="MovieDBContext"
connectionString="Data Source=.;Initial Catalog=Movies;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
Change Data Source to : Data Source=.;
or Data Source=.\SQLEXPRESS;
After that, you need to configure access right to App_Data. For Win7, On Security tab in properties Add user network Service with full right.
Found similar question:
asp.net mvc Invalid value for key 'attachdbfilename'
Or in my opinion, it might be just a typo in your connection string. Because you don't have escape character for (LocalDB)\v11.
Try writing Data Source=(LocalDB)\\v11
;
Upvotes: 6