ASP .Net MVC 4, Invalid value for key ‘attachdbfilename’

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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;


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x