asp.net mvc Invalid value for key 'attachdbfilename'

后端 未结 9 1555
野趣味
野趣味 2020-12-10 05:50

I am currently reading Manning\'s \"ASP.NET MVC 4 in Action\" book and trying to get the first example to work.

Within my test application, I built a simple Model a

相关标签:
9条回答
  • 2020-12-10 06:37

    I think the problems here is string in web.config is not correct According to your set up sql, the string will work if you set something similar like this

    <add name="MovieDBContext"
           connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Movies;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
           providerName="System.Data.SqlClient"
      />
    

    Data Source=.\SQLEXPRESS; --> sometime, it will be Data Source=.; after that, you need config right to access FOlder App_Data If u test on Window 7, right click folder. property Security tab -> add user network Service with full right

    0 讨论(0)
  • 2020-12-10 06:37

    Facing the same issue, I have looked over my connection string and found that "UNC-style" paths e.g. \\MyServer\MyDBServer are not allowed, one has to use the MyServer\MyDBServer syntax for a remote host or the .\MyDBServer syntax for locally hosted DB Servers.

    0 讨论(0)
  • 2020-12-10 06:38

    I tried finding a solution for this particular error without success.

    Fixed it in the end by updating the .Net Framework 4 to 4.0.2. Patch and details can be found Here is the link

    Hope it helps

    0 讨论(0)
提交回复
热议问题