4

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?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
TheSoftwareJedi
  • 34,421
  • 21
  • 109
  • 151

3 Answers3

4

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......

TheSoftwareJedi
  • 34,421
  • 21
  • 109
  • 151
Jose Basilio
  • 50,714
  • 13
  • 121
  • 117
0

SQLMetal

http://msdn.microsoft.com/en-us/library/bb386987(v=vs.110).aspx

The SqlMetal command-line tool generates code and mapping for the LINQ to SQL component of the .NET Framework. SqlMetal can perform several different actions that include the following:

From a database, generate source code and mapping attributes or a mapping file.

From a database, generate an intermediate database markup language (.dbml) file for customization.

From a .dbml file, generate code and mapping attributes or a mapping file.

This tool is automatically installed with Visual Studio.

SQLMetalPlus

A project where the .dbml can be autogenerated within Visual Studio with a refresh button.

http://www.codeproject.com/Articles/37198/SqlMetalPlus-A-VS-Add-in-to-Manage-Custom-Changes

SQLMetalPlus Forked on Github

Includes prebuilt installers.

https://github.com/thedemz/dotnet-sqlmetal-plus

The Demz
  • 7,066
  • 5
  • 39
  • 43
0

If money is no object, your best bet is to get the data modeling edition of visual studio 2008 team system, create a database project and use it to maintain the database, data model and the entity model. It's not zero work to keep the database and the entity model synchronized, but using the schema compare tool, it's not far from it (and it definitely does all the drudge work for you).

IMHO, the data modeling and design roundtripping more than justifies the high cost of buying the team edition of Visual Studio 2008 over the professional edition.

Jeff Leonard
  • 3,284
  • 7
  • 29
  • 27