I have a solution that NHibernate uses to generate a db schema based on mapping files. I am trying to tear this functionality out of a solution so that it can be used as a standalone console application. I was able to specify the path to the mapping files as follows:
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration(); Assembly contractsAssembly = Assembly.LoadFrom(@"C:\Data\Development\NHibernateTestMappings\Source\DomainModel\Core\bin\Debug\NHibernateTestMappings.Core.Contracts.dll"); Assembly assembly = Assembly.LoadFrom(@"C:\Data\Development\NHibernateTestMappings\Source\DomainModel\Core\bin\Debug\NHibernateTestMappings.Core.dll"); cfg.AddAssembly(contractsAssembly); cfg.AddAssembly(assembly); DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Data\Development\NHibernateTestMappings\Source\DomainModel\Core\Mappings"); FileInfo[] mappingfiles = directoryInfo.GetFiles("*.hbm.xml"); foreach (FileInfo fi in mappingfiles) { cfg.AddFile(fi.FullName);
So, when it comes to the point where he is trying to add a file, he complains that he cannot find the NHibernateTestMappings.Core assembly, because there is no assembly reference in my standalone application, but each mapping file contains an assembly reference:
<class name="NHibernateTestMappings.Core.Store, NHibernateTestMappings.Core" table="STORE" lazy="false">
What I need is to provide the nhibernate configuration with the path to my dll assembly, and not add a link to it so that I can just change the paths in app.config and generate my circuit.
source share