LocalSqlServer not found in application configuration or connection string is empty

I just upgraded the .NET 3.5 MVC 1 project to .NET 4.0 MVC 3 and for some reason, when I try to start it, it says:

The connection name "LocalSqlServer" was not found in the applications or the connection string is empty.

I'm not sure why it does it like not, where in my code it looks for the LocalSqlServer connection LocalSqlServer and if I insert the LocalSqlServer connection LocalSqlServer in my configuration file with the value of my standard connection string and try to go to the website, it will lead me to The login URL is, but with a 404 page (and not with a 404 user page).

Does anyone know what the problem is?

Yours faithfully,
Harry

+5
sql web-services asp.net-mvc-3
source share
1 answer

The LocalSqlServer connection string is defined in the Machine.config file.

If you do not have a default Machine.config file, it can be deleted. Then you will need to re-add it to your own Web.config.

My LocalSqlServer:

 <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/> 

Here you can find your machine.config file:

 C:\Windows\Microsoft.NET\Framework\[FRAMEWORK VERSION]\CONFIG\machine.config 
+18
source share

All Articles