Skip to content
Advertisement

LocalSqlServer was not found in the applications configuration or the connection string is empty

I’ve just upgraded a .NET 3.5 MVC 1 project to .NET 4.0 MVC 3 and for some reason now when I try to run it it says:

The connection name ‘LocalSqlServer’ was not found in the applications configuration or the connection string is empty.`

I’m not sure why it does this as no where in my code does it look for a LocalSqlServer connection string, and if I put in a LocalSqlServer connection string in my config file with the value of my standard connection string and try to go onto the website, it takes me to the ‘please log in’ URL but with a 404 page (and not the custom 404 page either)

Anyone know what the problem could be?

Regards,
Harry

Advertisement

Answer

The LocalSqlServer connection string is defined in your Machine.config.

If you don’t have a default Machine.config file, it might have been removed. You would then need to re-add it inside 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"/>

You can find your machine.config here:

C:WindowsMicrosoft.NETFramework[FRAMEWORK VERSION]CONFIGmachine.config
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement