Best Practices for Managing Linq to SQL Dbml Files

linq-to-sql

I've just started using Linq to SQL, and I'm wondering if anyone has any best practices they can share for managing dbml files.

  • How do you keep them up to date with the database?
  • Do you have a single dbml file for the entire database, or is it split into multiple logical units?
  • How does managing this file work in a team environment?

Any other tips and tricks welcome.

Best Answer

Have you looked at SqlMetal? It's officially supported, although not promoted too much. You can use it to build dbmls from the commandline - we've used it as part of a db's continous integration updates (make sure you have really good code separation if you do this though - partial classes are a saviour - as the dbml will get overwritten).

If I recall correctly it doesn't have quite the same features as the model designer in Visual Studio (I think it handles pluralisation differently). There a good post about it on Ben Hall's blog.