Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Practices for Managing Linq to SQL Dbml Files?

Tags:

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.

like image 336
tbreffni Avatar asked Aug 28 '08 23:08

tbreffni


People also ask

What is Dbml in Linq to SQL?

The DBML file is mapping that defines your classes based on your database schema. Yes, it defines your (default) connection string, but it doesn't "configure" your database at all. Linq to Sql uses a database-first approach where you have the database and model your classes after the DB schema.

What is the difference between Dbml and EDMX?

edmx is the modeling file for Entity Framework. dbml is the modeling file for Linq 2 Sql. You should spend your time learning Entity Framework as Linq 2 Sql is deprecated.

How do I download Linq to SQL?

To install the LINQ to SQL tools, start the Visual Studio installer, choose Modify, then select the Individual Components tab, and then select LINQ to SQL tools under the Code Tools category.


1 Answers

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.

like image 198
Gareth Jenkins Avatar answered Sep 24 '22 22:09

Gareth Jenkins