While working on a project with a LinqToSQL Classes object (.dbml), sometimes your dbml file will get hosed when you remove/add/modify some part of the data model. At first, my error was "The custom tool 'MSLinqToSQLGenerator' failed." , indicating that the LinqToSQL custom tool was failing. Oddly, what would happen is the code would end up deleting the .designer.cs file ... I googled around and found some other people who had the same issue, which for me was resolved taking the following steps:
- On your .dbml file, drill into the file and, if you are not using a partial class declaration, delete the <modelname>.cs file that's generated.
- Right-click the .dbml file and choose 'Run Custom Tool'.
This restores the <modelname>.designer.cs file, but that's only half the battle. For me, when generating the .designer.cs file, the Custom Tool no longer flagged that file as 'compile' in the build process, so while the 'custom tool' error was gone, my other 'missing data context' errors were still present. You then have to right-click on the <modelname>.designer.cs file, go to Properties, and choose 'compile' as the build action. Otherwise, you will continue to have missing <modename>DataContext errors .
Hope this helps someone! I was stumped.