Search code examples
nhibernatenhibernate-mapping-by-code

What are benifits of FluentNHibernate / NH Mapping by Code?


I tested with both FNH and NH mapping by code, they worked fine too but that's just my simple test, I still not identify pros & cons for each one. Any master there, could you show me some information ?


Solution

  • It is mainly a matter of taste and personal preference.

    The few, not very strong arguments I know about:

    FNH pros

    • FNH is older then mapping by code (which is brand new). There is a large community and useful documentation.
    • FNH is designed to be as simple as possible and is most probably easier to learn. There is a single way how it is meant to be used.
    • FNH has some more nice features, like mapping tests and auto mapping.

    Mapping by code pros

    • Mapping by code is a part of the NH core (while FNH is a forked project). It can be expected to get widely used and supported forever.
    • Mapping by code is most probably more powerful and flexible. It is a quite basic API and can be used in many different ways.
    • Mapping by code is closer to xml mappings, which makes it easier to adapt documentation.