2

Is it possible, to configure the Database connection the classic way in hibernate.cfg.xml, but use FluentNhibernate to map the entities?

What I tried is combining the classic configuration.Configure(); somehow with Fluently.Configure(), but I could not figure out a way yet.

Why would I want that? Because I'd like to deploy the same binaries to different customers running databases from various vendors. Thus I want to avoid compiling binaries for each supported database dialect. Maybe there is even a better approach than the one above?

1 Answer 1

1

You can load the nhibernate configuration normally, the use it with Fluently.Configure :

 // read hibernate.cfg.xml
 Configuration config = new Configuration().Configure();
 // load mappings from this assembly
 Fluently
      .Configure(config)
      .Mappings(
           m => m.FluentMappings.AddFromAssemblyOf<Program>())
      );
Sign up to request clarification or add additional context in comments.

2 Comments

AddMappingsFromAssembly doesn't seem to exist anymore in NHibernate 3 .
Wow I guess that was too straight-forward to find ;-) Thank you!

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.