score:2

Accepted answer

I think that replacing MSLinqToSqlGenerator with something else is the cleanest solution and it might be done in several ways. You could, for example,

  1. Use a tool like T4 Toolbox: LINQ to SQL classes generator or Reegenerator and modify the provided template to suit your needs. That's probably the easiest way.

  2. Generate the code with T4 using a custom template. You will need to create a T4 template which would use XML data from .DBML file. You'd probably need to disable DBML code generation by setting the Custom Tool property to blank. The disadvantage is you will need to run T4 generation each time after modifying .DBML file.

  3. Create a custom tool to generate the code for you using XML data from .DBML file and some templating solution (T4 or XSLT, perhaps). This approach could arguably be the most flexible one, the only disadvantage is that you'll have to use the custom tool on every developers' machine.

I'm not sure what's optimal for your situation, but I'd probably consider using T4 Toolbox first. The T4 template it uses is quite standard and can easily be modified if necessary.


Related Articles