1

I'm planning to write a code generator to generate UI (forms, grids, etc.). Since I'm using LINQ I'm planning to read a DBML file for metadata extraction purposes. Is there some API to read the DBML object model (database, tables, columns, and associations)?

I've opened SQLMetal.exe with Red Gate Software's .NET Reflector. It contains a namespace called LinqToSqlShared.DbmlObjectModel and it seems it contains everything I need to read a 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, does something exist, like the LinqToSqlShared.DbmlObjectModel namespace, to read DBML to an object model in .NET.? Or do I have to write it my self?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291

2 Answers2

1

Have a look at how the model is read in L2ST4 project. You could reuse the T4 file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Luc
  • 26
  • 1
  • 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 Dec 14 '09 at 17:06
0

Take a look at a tool like Reegenerator. We're considering this as a replacement for the L2S code generator, because we've got some specific code generation requirements.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Randy Minder
  • 47,200
  • 49
  • 204
  • 358
  • 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 Nov 11 '09 at 23:56