Some words about NHModeller. The basic idea is to have a central point where you define the entities of your model, that is not the Xml Mapping itself,neigther a databse schema nor the classes. The idea actually is not so different from modelling starting from the mapping files, but Xml is orrible to write, even with intellisense. NHModeller aim to make simpler writing a mapping, and generates the real one as one of the artifacts.
The project uses MGrammar as a parser generator for the DSL and Intellipad as the preferred editor. Both these comes from the Microsoft "Oslo" Project, still CTP at present.
The version I have developed till now deal correctly with:
- Native Keys ( implicit ) or any other simple key ( not composite )
- Property Mapping
- One-To-Many mappings
- Many-To-One mappings
- Many-To-Many Mappings
- Lazy / Eager fetching
I will post here a screenshot of the actual present version, running a just for fun blog model:
When a model is created, we have to launch the code generation. This is achieved by a console application, and intellipad is just spawning the process after asking the parameters.
The UI is not so good, due to my inexperience both in WPF and intellipad :(
After the generation we can have a glance to the artifacts generated we have:
Xml for NHibernate mapping
And, expecialli thanks to NHibernate SchemaExport class, the DDL for our preferred DB ( at least if it is NH compliant )
The DDL is the most interesting part, expecially for me that I hate dealing with DB schemas... Here below an example of a DDL created for the blog model for SQL Server and Oracle.
Well, there is some more works, even if the generator till now let a newbie to start using NHibernate in minutes. We just need to compile the files in an assembly ( remember to put "Compile as" "Embedd Resource" for the hbm files), and start using the model.
Further Step-- Let use SchemaUpdate to modify a running model, deal with Components, Composite Key, Indices, One-to-One mapping.