A few weeks ago, I started noticing that every time I opened a LINQ to SQL .dbml file in Visual Studio 2008 I would get an alert message that said "The connection property in the web.config file is missing or incorrect. The connection string from the .dbml file has been used in its place."

The dbml file was configured to reference a connection string in the web.config file, but after I got this alert and clicked OK, Visual Studio would check out the project and add a new Settings.settings file under the Properties folder and generate a new connection string there, and then change the dbml file to reference that instead of the web.config.

This would probably be the behavior you would expect if the web.config was really missing the connection string, but in my case the referenced connection string was there and well-formed. I know this, because the related code was under source control and other developers could open the same dbml file (from the shared code base) and they wouldn't get the alert and everything worked flawlessly.
To me, it seemed like the LINQ to SQL designer on my machine was simply having trouble reading from the configuration file ... so I thought it might be an issue with a particular dll or registry entry. Another thing that convinced me of this was the fact that when you were in the dbml editor ... under the Connections property on my computer, none of the connection strings from the web.config were included in the drop down to select from. But, when another developer would look at this on their machine (using the same exact code base and files), their Visual Studio environment would find those connection strings in the web.config and include them in the list to select from.
.png)
.png)
I figured out that I could just undo the changes to add the new file, and then view the differences of the dbml file's XML and undo the reference change to make it once again reference the web.config instead of the settings file it created ... and that worked fine for a couple weeks, but eventually jumping through those extra hoops that "should just work" got pretty old.
So I first tried to repair my Visual Studio install, but that didn't work. Next, I completely uninstalled Visual Studio and then re-installed it and the related service packs ... but that didn't work either. I was about to just format my machine and re-install Windows ... but I thought I would give Microsoft Support a chance, hoping they could help me. I knew this was an obscure enough problem that they probably wouldn't be much help, but I really hate paving my machine ... so it was worth a little time to give them a chance. After explaining what was going on to a technician, we tried to use ProcMon to figure out what was going on behind the scenes. We noticed several registry errors, and that further convinced me that the problem was corrupted or missing registry keys. The support technician said he would have to look into it more, but I wasn't going to count on them as my only hope for a solution ... so I kept investigating myself. Apparently when you uninstall Visual Studio, it doesn't remove all of the registry keys. It also doesn't overwrite them all when you run a repair. It doesn't even remove them all when you remove all the other software that might have hooks or add-ins related to Visual Studio. So these corrupted or missing registry keys could have persisted through the repair and re-install.
Here are some of the issues we noticed in ProcMon (it is a snapshot of what was happening when I would open the dbml file and the pop-up alert would appear, and then I would click OK). The one highlighted is the what I was guessing was the culprit, because that missed registry key occurred right between the read of the dbml file and the opening the related project (which I am guessing was to create the new settings file). You can ignore the "Fast IO Disallowed" stuff, because that is unrelated.

So, although the support technician had actually explicitly advised me not to do this ... I decided to uninstall Visual Studio (and any other software add-ins that might be related to it), manually delete the related registry keys contained in any folder that appeared related to Visual Studio, and then do a fresh install. I never think hacking in the registry is a good solution to a problem, but this was my last ditch effort ... and I was resolved to do a full re-install of Windows if it didn't work. To my surprise ... it actually worked.
I can't guarantee this will work for you, or even recommend it ... but here are the registry folder locations I manually deleted:
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio
- HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio
- HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSCommon
- HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSTAHost
Hopefully if you are still reading, this is the exact problem you are having and this will work for you as well. The only thing I can say is ... it worked on my machine, and it saved me from having to completely re-install Windows to fix the problem.