NHibernate Code Generation

前端 未结 6 1616
野的像风
野的像风 2020-12-10 19:59

I am working with NHibernate, and a few code generation tools. MyGeneration is one and SmartCode is the other.

This question has been asked before, but I have looked

相关标签:
6条回答
  • 2020-12-10 20:27

    You may want to keep an eye on ABSE (http://www.abse.info). ABSE is a code-generation and model-driven software development methodology that is completely agnostic in terms of platform and language, so you wouldn't have any trouble creating your own generators for NHibernate, MSSQL 2008 and anything else you wish. The big plus is that you can generate code exactly the way you want. The downside is that you may have more work to do at first to build your templates.

    Unfortunately, ABSE is still work in progress and an Integrated Development Environment (named AtomWeaver) is still in the making. Anyway a CTP release of the generator is scheduled for January 2010, so we're already close to it.

    0 讨论(0)
  • 2020-12-10 20:32

    I was using Adapdev's Cudus in the past and now I'm using NConstruct (http://www.nconstruct.com) because I need also application generation, not just NHibernate mapping files.

    It doesn't support SQL 2008 and I've contacted them about this issue because I also plan to migrate from SQL 2005 to SQL 2008 in the near future. According to their response newer versions will support it but I don't know when. Maybe more of us need to push them to get SQL 2008 sooner. Otherwise I like this tool very much.

    0 讨论(0)
  • 2020-12-10 20:33

    The NHContrib project includes a tool called hbm2net to generate code. I've never used it, so I've no idea what sort of code it produces, but I know it uses NVelocity. Link to a tutorial.

    0 讨论(0)
  • 2020-12-10 20:35

    I've used CodeSmith and been very happy with it. I haven't used their NHibernate template but I know it is just one of the many frameworks they support. Have a look here.

    0 讨论(0)
  • 2020-12-10 20:40

    I strongly recommend you take a look at Visual NHibernate from Slyce. I have used all tools out there both free and commercial and found it to be the only one that does exactly what it says on the can and more.

    It allows you to design your entities either from the ground up or from an existing database.
    (source: slyce.com)

    It is compatible with most existing dbs

    with future suport for Postgresql.

    It allows you to customise your entities to your specs
    (source: slyce.com)

    Other than its ability to go back and forth smoothly between entities and db during design, my most favorate feature is the Diff View


    (source: slyce.com)

    which shows changes it will make to code before it generates the code. So not only can you see the effect of your changes but you can also cancel the codegeneration in time or simply output to a different folder.

    This tool has many many fine features and is now mature. Lastly, there is a 30% discount going on so ;-)

    0 讨论(0)
  • 2020-12-10 20:48

    I suggest taking a look at the Summer of Nhibernate series by Steve Bohlen, specifically Session 8 which talks about using NHibernate with a a pre-existing/legacy datastore situation. He uses MyGeneration and provides the template file he uses for doing so.

    0 讨论(0)
提交回复
热议问题