Overwrite NHibernate classmapping with FluentNHibernate - nhibernate

We have a developed a new product based on a legacy database.
We use NHibernate for our DAL and FluentNHibernate for mapping.
The developed product is mostly standard software, however we have one customer which uses a slightly different database for its backend.
Now, we already have an infrastructure in place to load specific modules dynamically.
Our idea was to overwrite several entity mappings in such a module. However, we can't find a way to overwrite the NHibernate classmappings.
What would be the best approach to overriding an already mapped class using (fluent) NHibernate?

Why don't you separate the mappings and then load the assemblies dynamically.

Related

nhibernate mapping generator integrated to build

I have searched for automatic mapping generator for nhibernate. So far I have tried following
NHibernate Mapping Generator
Devart Entity Developer
Codesmith generator
From those Nhibernate Mapping Generator is the only one that supports NH style fluent mapping by default. Devart and codesmith provides possibility to write own templates that would do the job. Devart and Codesmith also has "challenges", when you want mappings and entities be located in different assemblies.
I would like to ask, if you guys have any experience from the tools above? Also if you have any other tools you could suggest to me.
I am also interested in integrating those tools into CI environment. Whenever DB changes, I want entities and mapping be generated automatically.
I use Devart Entity Developer and it does support fluent nHibernate mapping. In-fact I use this on all of my projects. You simply add the fluent template from those provided and configure the output location. It generates the mapping code files automatically based of the model you load in from your database every time you build the project. It integrates well into Visual Studio if required. I would thoroughly recommend you give the 30 day trial ago.
Devart Entity Developer
In particular I draw your attention to this paragraph:
Entity Developer NHibernate mapping generator can generate both XML and fluent mapping. For XML mapping you may customize output settings, use the File per class option. XML mapping is generated as an embedded resource by default. Our NHibernate designer provides full support for Fluent NHibernate mapping - it supports all kinds of inheritances, components, composite IDs, etc.

Use RavenDB as the database for an Orchard CMS module

I'm just getting underway with Orchard CMS. How difficult would it be to create an Orchard module that uses RavenDB as its database? Is a hard dependency on SQL and NHibernate baked deeply into Orchard?
All of Orchard's core features are based on NHibernate so it would be difficult to move the entire Orchard database to another DBMS not supported by NHibernate. However, Orchard is very extensible and it is quite easy to access all kinds of custom data sources from your own modules. For example, I am currently working in a project where we store our data in a graph database (neo4j) and access them in Orchard using a WCF service.
It depends on what kind of data you need to access, but you will probably need to create a custom content part which dynamically loads data instead of using the underlying SQL database through NHibernate. You can do this by inheriting from the non-generic ContentPart class (the generic one uses a record stored using NHibernate) and using a ContentHandler to populate the data from your custom data source.
There is an experimental RavenDB-based data layer implementation in 'ravendb' Mercurial branch.
It was built a couple of months ago and I'm not sure about the compatibility with the current release, but you can give it a try. There were no big changes to DL since then so I assume it should work or need just a couple of tweaks.

Using NHibernate for DotNetNuke Modules?

I'm thinking of adopting a more Domain-Driven-Design approach to DotNetNuke module development and would like to consider using NHibernate as an OR/M layer.
Does anyone have experience using NHibernate with DotNetNuke? I've used SubSonic and EntitySpaces, but not NH.
UPDATE
Sorry, I should have been more clear. Is NHibernate capable of running in Medium Trust and able to run in the context of the DotNetNuke "objectqualifier" ? The DNN object qualifier is essentially a prefix that can be applied to all database table names. So on my DNN install I might have a table named "Products", but on someone else's the same table might be named "dnn_Products" where the "dnn" is the "objectqualifier". So essentially NHibernate would need to read the objectqualifier from the web.config at runtime and apply it.
NHibernate can be used with essentially any table name. When you define the table mapping in your mapping xml you need to simply define the table name as dnn_Products. As long as that is the actual name of the table then it will work. NHibernate is capable of running in Medium Trust, the trick is getting the NHibernate dll's into your DNN install. You can add them in an Assembly Component from what I understand but I have never had the need to validate that personally.
You can see this example.
The article is not for the same topic you are looking but it will give you good idea about it.

Using Schema Export Efficiently

We are using NHibernate as our ORM framework.
We have a need to persist classes we load at run time. We do that according to metadata they come with, that holds names and types of the data they have.
In order to build the tables for them at run time, we use the SchemaExport class from the NHibernate ToolSet API.
We wanted to ask two questions:
Is there a way to make NHibernate do all the actual creations in one roundtrip to the DB instead of a roundtrip per table?
In order to use the SchemaExport tool are building a dynamic string that represents a mapping file from a template we keep. Is there a better way to do this? Maybe even without a mapping string?
Ad 2.
If I understand you correctly, you don't want to use hbm mappings, right? Have you considered using Fluent NHibernate? (http://fluentnhibernate.org/)

nHibernate - Generate classes from a database?

I know that you can generate a database from classes and their mappings using nHibernate, but I can't find any good links to do this the other way around. We have a database that has already been designed, and we are looking at using nHibernate. It would be nice to use a tool to generate the mappings and classes from the database, and then we could tweak/manipulate them to suit our tastes.
NHibernate Mapping Generator
You can use nhibernate with an existing database. It is a matter of writing the mapping files.
I also recommend using Fluent Nhibernate...I started using this after this community recommended it..
Look at subsonic as well if you do not like maintenance of mappings.