I'm thinking of using SqlMetal to auto-generate LinqToSql code for a simple and small database. The database will have only tables with some primary and foreign keys (i.e., no views, stored procedures, functions, etc.). I'd like to do all joins, grouping, sorting, and advanced data manipulation using Linq.
I have experience with LinqToObjects and LinqToXml, but I've never used a proper ORM or LinqToSql.
Some questions:
- How steep is the learning curve for SqlMetal/LinqToSql, given my prior experience?
- Is SqlMetal reliable for simple databases?
- What kind of surprises, if any, might I encounter?
- How would I automate my project so that the LinqToSql code gets regenerated every time I build or, better yet, rebuild my project? (I will be using Visual Studio 2008.)
- Can you recommend a good tutorial for getting me up to speed quickly on using SqlMetal and LinqToSql?
The answer to your title question is yes it is a fine solution for database with tables only (and to a point can grow when your database grows to include other database constructs like views and stored procedures).
SubmitChanges()
.As to your goal of using Linq2SQL for everything, be ready for some nasty LINQ queries (and nasty debugging cycles). The join syntax is verbose and depending on the complexity of your queries can quickly become harder to maintain than the SQL equivalent. Grouping isn't as easy as
GROUP BY
.