I have a solution that uses NHibernate to generate the db schema based on the mapping files. I'm trying to break that functionality out of the solution so it can be used as a stand alone console app. I was able to provide a path to the mapping files like so:
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);
//cfg.Configure(myAssembly, fi.FullName);
//cfg.AddResource(fi.FullName, myAssembly);
}
So when it gets to the point where it tries to add the file it complains that it can't find the NHibernateTestMappings.Core assembly because there is no reference to the assembly in my standalone app, but each mapping file contains a reference to the assembly:
<class name="NHibernateTestMappings.Core.Store, NHibernateTestMappings.Core" table="STORE" lazy="false">
What I need is a way to provide the nhibernate configuration a file path to my assembly's dll rather than adding a reference to it so that I can just swap out paths in an app.config and have this generate my schema.