NH Code First For Dummies?

130 views
Skip to first unread message

Marcelo Grossi

unread,
Apr 8, 2012, 8:35:21 AM4/8/12
to nhusers
Hi,

I'm trying to build a mapping for NHibernate 3.2.0 using the code
first approach and mapping all by code (I find it more elegant than a
bunch of XML files). I'm taking a beating from NH for a few days now
and decided to ask for you NH Gurus out there for help.

I'm having trouble mapping a custom "Coordinate" value-type class that
holds latitude and longitude. I made an ICompositeUserType for it but
can't get it mapped for the love of me! The reason I want a type for
it is that I will reuse this in several other entity classes.

My mappings are all in separate classes that derive from ClassMapping
(the entities at least).

Is there any books or references I can start? I couldn't find a
definitive manual/help for NH 3.2 code first (ByCode). Any
suggestions? Something that will show me all the possible
configurations and thought process I should be picking up on..?

Sorry for the long post, any help is much appreciated.

Thank you

Tom Bushell

unread,
Apr 9, 2012, 10:55:10 AM4/9/12
to nhu...@googlegroups.com
Check out Adam Bar's series on NH Mapping By Code, starting here:

http://notherdev.blogspot.com/2012/02/nhibernates-mapping-by-code-summary.html

This is by far the best info currently available (AFAIK), and really should be included with the NH docs.

-Tom Bushell

Marcelo Grossi

unread,
Apr 10, 2012, 12:36:34 AM4/10/12
to nhusers
Thank you very much Tom,

The link you sent was great!

Altough I still miss some 'official' documentation or perhaps a good
book on the inner workings of the ORM, I'm starting to get along with
NH instead of getting beat up by it day in and day out ;-)

Regards,

Marcelo Grossi

On Apr 9, 11:55 am, Tom Bushell <tbush...@bic.com> wrote:
> Check out Adam Bar's series on NH Mapping By Code, starting here:
>
> http://notherdev.blogspot.com/2012/02/nhibernates-mapping-by-code-sum...

Tom Bushell

unread,
Apr 11, 2012, 10:45:57 AM4/11/12
to nhu...@googlegroups.com
Glad I could help.

You might also want to consider using Fluent NHibernate - it's been around longer, and is more mature and better documented.  Adam has some good comparisons in his blog posts.  I agree with some of his criticisms of FNH vs NH MbC, but not all of them.

In particular, I suggest looking at FNH Automapping (http://wiki.fluentnhibernate.org/Auto_mapping).  I've been using this on my project for almost 2 years now, and it mostly "just works".

NH has nothing equivalent yet, although I've seen some recent postings here indicating it's being worked on.

-Tom Bushell

Marcelo Grossi

unread,
Apr 11, 2012, 4:54:49 PM4/11/12
to nhusers
Hi Tom,

Is FNH still being developed? I thought that the latest commits to
their source control was from quite a few years back..

Regards,

Marcelo Grossi

Tom Bushell

unread,
Apr 12, 2012, 11:23:42 AM4/12/12
to nhu...@googlegroups.com
FNH development has been slow recently, because the main developer, James Gregory, has taken a new job in Australia. 

This has left him with little time to work on FNH.  But people are still submitting fixes, and another release is planned, date unspecified.

That said, I'm also a little concerned about the slow pace, and considering other options. 

For my particular application (scientific data collection and analysis), there's very little relational data, so a NoSQL solution might be a better choice.

RavenDB looks particularly interesting.  Seems to offer all the convenience of FNH automapping, while greatly reducing the complexity associated with persisting everything to an underlying relational database.

-Tom

Marcelo Grossi

unread,
Apr 13, 2012, 5:46:15 PM4/13/12
to nhusers
Hi Tom,

My application makes heavy use of relational data and NH is by far the
better option out there (that I have tested). I started out initially
with majorly overrated Microsoft Entity Framework. I didn't support
any real world scenarios I had it faced against. NH however is proving
to be a champ!

Marcelo Grossi

TheCPUWizard

unread,
Apr 13, 2012, 6:34:37 PM4/13/12
to nhu...@googlegroups.com
Marcelo,

I use both NH and EF for many different projects. There are cases where EF
is clearly superior and cases where NH is the winner. I do not see it as
better/worse, but more of the right tool for the system and desired
architecture.

David

Hi Tom,

Marcelo Grossi

--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to
nhusers+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.

Marcelo Grossi

unread,
Apr 14, 2012, 10:43:08 AM4/14/12
to nhusers
Hi David,

Can you be more specific on the cases where EF is clearly superior?
I'm very interesting in knowing the boundaries here if possible.

Thanks for the input,

Marcelo

Vahid

unread,
Apr 15, 2012, 12:04:16 AM4/15/12
to nhu...@googlegroups.com

Frederic

unread,
Apr 14, 2012, 5:23:00 AM4/14/12
to nhu...@googlegroups.com, nhusers
Raven is à layer over Ms essent.(nicely packaged)
For heavy calculation on temporal data, rdbms are not à good choice. You should look for mongo, membase, or even appfabric.
My 2 cents.
F.


Envoyé de mon iPhone

Marcelo Grossi

unread,
Apr 17, 2012, 5:21:55 PM4/17/12
to nhusers
Hi Frederic,

Thanks for the input. It's not so heavy a calculation. It should be
fairly light.

Marcelo

On Apr 14, 6:23 am, Frederic <f...@free.fr> wrote:
> Raven is à layer over Ms essent.(nicely packaged)
> For heavy calculation on temporal data, rdbms are not à good choice. You should look for mongo, membase, or even appfabric.
> My 2 cents.
> F.
>
> Envoyé de mon iPhone
>

Angel Java Lopez

unread,
Apr 17, 2012, 6:20:39 PM4/17/12
to nhu...@googlegroups.com
Hmm... what mean "Ms essent."? 

Tom Bushell

unread,
Apr 18, 2012, 10:28:25 AM4/18/12
to nhu...@googlegroups.com

 

Here’s a link about ESE, the underlying Windows store that RavenDB uses - http://en.wikipedia.org/wiki/Extensible_Storage_Engine.

 From the article:

Extensible Storage Engine (ESE), also known as JET Blue, is an Indexed Sequential Access Method (ISAM) data storage technology from Microsoft. ESE is notably a core of Microsoft Exchange Server and Active Directory. Its purpose is to allow applications to store and retrieve data via indexed and sequential access. Windows Mail and Desktop Search in the Windows Vista operating system also make use of ESE to store indexes and property information respectively.



On Tuesday, April 17, 2012 6:20:39 PM UTC-4, ajlopez wrote:
Hmm... what mean "Ms essent."? 

On Sat, Apr 14, 2012 at 6:23 AM, Frederic wrote:
Raven is à layer over Ms essent.(nicely packaged)
For heavy calculation on temporal data, rdbms are not à good choice. You should look for mongo, membase, or even appfabric.
My 2 cents.
F.


Envoyé de mon iPhone

Reply all
Reply to author
Forward
0 new messages