Sql – LINQ2SQL: If I make changes to DB, how to mirror them in DBML

linq-to-sqlsql-server-2008visual-studio-2008

I am using LINQ2SQL in my current project. I have a quite a lot of tables ~30. When I create my DBML file I change some of the column names etc for readability.

Recently if I made a change to the table in the underlying Database I just deleted and re-added the table in the DBML file, but this is getting tedious. How can I mimic any changes to the database in the DBML file? (e.g. new column, drop column, new default constraint etc).

Best Answer

Out of the box, Linq-to-SQL has no update feature - amazing, but unfortunately true.

There's two tools I know of that get around this:

  • PLINQO is a set of CodeSmith code generation templates which handle DBML generation and offer lots of extra features (like generating one file per db entity) - including updates!

  • The Huagati tools offer updates and enforcing naming conventions for DBML and Entity Framework

Marc