views:

239

answers:

2

Im planning to write a code generator to generate UI (forms, grids, etc.). Since i'm using Linq i'm planning to read dbml file for metadata extraction purposes. I wonder if there is some Api to read the Dbml object model (database, tables, columns, asociations).

I've opened SQLMetal.exe with Red Gate's .NET Reflector, it contains a namespace called LinqToSqlShared.DbmlObjectModel and it seems it contains everything i need to read dbml object model. The bad news is: that namespace is not exposed for external consumption and all classes are declared as "Friend" (or sealed).

Once again, do somebody knows if exists something like LinqToSqlShared.DbmlObjectModel namespace to read dbml to an object model in .net.? or do i have to write it my self...? :'(

A: 

Have you taken a look at a tool like Reegenerator (http://www.reegenerator.com/)? We're considering this as a replacement for the L2S code generator because we've got some specific code generation requirements.

Randy Minder
I've seen the tool you talk about, i've seen the video and it seems pretty interesting. However i will use T4 templates for code generation wich is pretty easy to implement and create customized code. The only thing i need is to extract object model from dbml file.
Javier Pitalua
A: 

Have a look at how the model is read here in the L2ST4:

http://l2st4.codeplex.com/

you could reuse the tt file.

Luc
Excelent!, this is exactly what i wanted to do.The class Data does the fantastic job for me. However implementation in a .tt file requires some human interaction, what i really want is to create a command line tool to generate classes and even user interfaces in an automated way. For now i've isolated the [Data] class in a dll to work in vb.net (wich is the language i am familiar with ;) )i will let you know how it goes. thanks for such a fantastic piece of code. you save several weeks of work. i owe you a beer.
Javier Pitalua