views:

340

answers:

1

I usually use Codesmith & NetTiers for my datalayers, and as they can be run from the command line it just requires a simple batch file to regenerate / rebuild everything whenever changes are made to the database.

Now I'm looking at LINQ-to-SQL, but I'm not finding the WYSIWYG entity designer as convienient. What other methods are available to generate the LINQ-to-SQL classes? Does anyone have any experience of using SQLMetal?

Thanks.

+3  A: 

SQLMetal is fine for generating the model classes. I am not very fond of the LINQ designer, so typically, I will use the designer in the initial design phase, and later additions or alterations to the datamodel is then done by hand editing the dbml file.

I use this simple command for building my LINQ-to-SQL classes, which I put in a batch file for maximum convenience:

sqlmetal /code:YourCodeFile.designer.cs /namespace:Desired.Namespace YourModel.dbml

The SQLMetal approach works fine for me, and is a reliable way of generating the code. Any handwritten additions to the generated classes, should of course be kept in partial class declarations in a separate code file.

driis
Thanks Chris, your suggested batch file now works in conjunction with a CodeSmith (www.codesmithtools.com) template to generate the datalayer / entites etc.. while I read the paper :)
Nick