The only limitation is that you wouldn't be able to use the same ISessionFactory for both sets of mappings. In general an ISessionFactory can only support one database at a time. If it is the case that you'll need to access one database per application instance, but you only need to choose the schema at runtime, then what you need to do is certainly supported with NH. It isn't the base configuration, but not hard either.
A quick sketch of one possible approach for that: build two (or n) resource assemblies, one for each schema version. Then at the point in your application when NH is configured and the ISessionFactory built, you can determine which schema you need (either from an indicator in the DB or from your .config file), and call AddAssembly() with the approprate resource assembly.
Variations can also be acheived using AddFile() and AddResource() for your mappings.
I have done something like this on a smaller scale: I have one class that can vary between two table schemas. So, I named the two mapping resources for it with a '.<schema indicator>.ohbm.xml' extension. The 'ohbm' ensures that they aren't loaded with the rest with AddAssembly(), and then I can choose which to load using AddResource() and the schema indicator from my .config.
Good luck. I'm sure you'll find NH to be an invaluable tool.
|