5

at start i'll tell you that i'm totally green with Nhibernate but i was wondering how to use Nhibernate into already made DataBase. The DataBase at itself is rather large (the part of it i'm using on my CPU to test on is 1gb). I'm not a huge fan of mapping by xml. I thought that this tool might help me (https://www.devart.com/entitydeveloper/) but it's performance is not satisfying. So am i supposed to go with code and then just map it with XMLs or what are my other possible ways i could go with?

Kacper Werema
  • 448
  • 2
  • 5
  • 18

2 Answers2

3

There are two options that I know of:

  • Fluent NHibernate: Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate
  • NHibernate.Mapping.Attributes: With NHibernate.Mapping.Attributes, you can use .NET attributes to decorate your entities and these attributes will be used to generate the mapping information
Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • 1
    In addition to the above two addons, NHibernate have built-in support for "Mapping-By-Code". No need for XML. – Oskar Berggren Aug 02 '16 at 12:14
  • I second mapping by code. it's as flexible by xml, but meant to be faster since there is no xml mappings to parse at session factory startup. If I remember correctly Fluent under the covers creates the xml on the fly so sessionfactory startup isn't so fast. There's also a great resource for mapping by code and fluent here http://notherdev.blogspot.com/2012/02/nhibernates-mapping-by-code-summary.html – Fran Aug 02 '16 at 13:02
0

Unless you have a requirement for NHibernate I would highly recommend Dapper especially if your concern is performance. For CRUD you can look into Dapper Contrib or Dapper Rainbow.

Dapper Rainbow vs Dapper Contrib

Introduction to Dapper

Community
  • 1
  • 1
zulqarnain
  • 1,695
  • 1
  • 16
  • 33
  • Can `Dapper Contrib` or `Dapper Rainbow` generate models from existing db? – Konrad Mar 13 '18 at 20:51
  • 2
    It may or may not be the case that Dapper is better - that is really an opinion-based discussion rather than a matter for a StackOverflow question. But either way, this question is about NHibernate specifically, so this is not an answer. – Stephen Holt Jul 05 '18 at 08:31