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?

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

2 Comments

In addition to the above two addons, NHibernate have built-in support for "Mapping-By-Code". No need for XML.
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 notherdev.blogspot.com/2012/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

2 Comments

Can Dapper Contrib or Dapper Rainbow generate models from existing db?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.