This is driving me nuts. I think it is because of some connection string mismatching across the app (using MVC) but Visual Studio constantly takes my .designer.cs file and recreates it adding a '1' at the end (or 2 if it already did this before argh!). My question is two-fold: Is there a way to stop VS from doing this? But more importantly: How can I manually set it back to the original .designer.cs or is that not possible? I try to delete the new one it created (because I keep getting duplicate definition build errors) and it won't automatically associate back with the original one in the DBML file structure in solution explorer.
Does anyone have a solution for this madness?
Not an ideal solution, but a workaround would be the following. In Visual Studio, go into the properties of the .dbml file and clear out the Custom Tool
property. This will prevent it from running the auto-generator against the DBML and creating the designer files. Of course further changes to the DBML won't be reflected in the designer file.
As for why it's generating multiple designer files, that's an oddity. To manually associate a file under another, you need to modify the project file. Look for a line like
<Compile Include="file.designer.cs" />
and change it to
<Compile Include="file.designer.cs">
<DependentUpon>file.dbml</DependentUpon>
</Compile>