4

I would like to set up a very simple demo application that includes LINQ over NHibernate. While I wait for an answer, I'm doing other tasks :)

  • I don't like HBM files at all
  • I need to set up a very simple database schema (3 tables)
  • I wouldn't exactly like to start from the DB. Maybe class model could be a better beginning
  • I haven't chosen target DB: probably MySQL

I know how to create a data model from HBM files. I know how to extract the data model from DB to .NET's Entity Framework but I believe my demo could be better done with NHibernate.

Can you suggest me a quick-start tutorial? I knew there was an old NH plugin based on annotations: that could be a suitable starting point...

usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
  • 7
    [Fluent NHibernate](http://www.fluentnhibernate.org/) with [Auto Mapping](http://www.jagregory.com/writings/fluent-nhibernate-auto-mapping-introduction/) might be worth a look. – Adam Houldsworth Jun 26 '12 at 17:31
  • 2
    NHibernate 3.2 on has mapping by code so that you don't need to use FluentNHibernate. – eulerfx Jun 26 '12 at 20:35

1 Answers1

1

Like Adam suggested, one option for you is to use FluentNHibernate and it's Auto mapping. Although, since your setup is really small, you could use the Fluent mapping as well.

Apart from the FluentNHibernate wiki, here are some resources:
Your very first NHibernate application by Gabriel Scheker
Getting Started With Fluent NHibernate and Auto Mapping in C# by Jason Mitchell

Another alternative with more recent version of NHibernate is mapping by code. This SO question has more than enough links, so I won't repeat them here.

As for attributes mapping, I suggest that you avoid it. They aren't used that much and you kind of poison your domain / POCO classes with data access concerns.

Community
  • 1
  • 1
Miroslav Popovic
  • 12,100
  • 2
  • 35
  • 47