Just got burned by this: http://connect.microsoft.com/VisualStudio/feedback/details/361577/mslinqtosqlgenerator-fails-with-partial-class-having-a-using-at-the-top-of-the-file
Symptom:
Linq breaks and exiting/restarting doesn’t fix it. Your database project is now missing a ‘.designer.cs’ file under your .dbml file.
Cause:
If you put a ‘using’ statement at the top of a partial class for a linq to sql database file (we routinely recommend making these partial classes to replace the default constructor, e.g. http://blog.arkesystems.com/post/2008/03/Using-the-connection-strings-in-your-webconfig-for-LINQ.aspx ) then sometimes Visual Studio deletes your .designer.cs file and so your linq just quits compiling.
Workaround is to move the using statement inside the namespace declaration, then restore your now-deleted .designer.cs file from version control or backups or else right click on the .dbml file and select "Run Custom Tool" to rebuild the file.
Timebomb, one day might kaboom:
using System.Configuration;
namespace Symmedian.SST.Data
{
partial class MyLinqDataContext {
Perfectly happy and fine:
namespace Symmedian.SST.Data
{
using System.Configuration;
partial class MyLinqDataContext {