visual-studio-2008linq-to-sql.net-3.5sqlmetal

Is it possible to auto-generate my Linq2Sql DBML via a script?


I use Linq2Sql and am tired of recreating the dbml everytime the database changes. Is it possible to script the creation of my model given that I want ALL tables and ALL procs? Ideally it would be part of the build process or a custom tool.

A simple "refresh from schema" button would be fine too, but from all I can tell, there is no such thing. Currently the only way I have to update my model is to delete the tables and procs that were changed and re-drag them over from the server explorer.

Maybe I'm missing something?


Solution

  • I suppose you can use the SQLMetal command tool

    EDIT by OP: I ended up writing a batch file to checkout the code, generate the classes with this, then commit the code. Then I created a database schema change level trigger to run this batch file anytime the schema changed. So now, when the schema changes, the Linq classes get created, checked in, then CCNet creates the DLL and distributes it. sweet......