views:

359

answers:

2

Hi guys, Does anyone have experience with generating database schema from c# (.net 3.5) domain model? Which of the tools produces the cleanest script?

Telerik OpenAccess ORM would have been ok but it doesn't produce clean column names from c# classes if the property fields use .net 3.5 implicit private fields.

I just need an initial script gen which I will then enhance and maintain manually.

P

+2  A: 
Pita.O
Awesome, did you use LINQ to Entities to walk the assemblies?
RobS
No. just used Assembly.Load(...) and the types in System.Reflection
Pita.O
A: 

P,

I have used Reflection, Introspection (FxCop SDK) and CodeModel (Visual Studio Automation) to solve a similar problem. I went from one API to the next in this order and like CodeModel best. The problem with Reflection is that it locks assemblies in memory as long as the AppDomain is loaded. This is a problem in T4, although you may not have it with your standalone executable. With T4 you couldn't recompile the original assembly after generating code from its metadata. Introspection worked well, didn't lock the assemblies, but it's still not documented, plus it requires you to compile the assembly before you can use its metadata. CodeModel is both documented and allows you to access metadata directly from C# source code.

Hope this helps, Oleg

Thanks, Oleg: I didn't have this problem perhaps and don't expect it with console.app scenarios. Your comment about T4 is interesting, though. Just wondering how the ASP.NET MVC guys do it with t4.By the way, do you think this locking problem will still remain if you copied the target types local?
Pita.O