Tuesday, April 27, 2010

VS 2008 SP1 deletes .dbml designer file – a solution

Also me was surprised after installation Visual Studio 2008 SP1. every little change in dbml hierarchy give raise to deleting designer file. Short googling return elegant solution:
In partial class move all using statements after namespace
Linq

Original code:
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Reflection;

namespace Test
{
partial class DataClassesDataContext
{
//...
}
}



New Code:

namespace Test
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Reflection;

partial class DataClassesDataContext
{
//...
}
}



Right click on the .dbml  file and run “Run Custom Tool”.

Enjoy!

No comments: