このチュートリアルに従おうとしていますが、マッピングを含む期待される hbm.xml ファイルを生成する代わりに、次のようなエンティティの単純な .cs クラスを生成します。
public class ProductMap : ClassMap<Product>
しかし、私はすでにそれらを自分でコードで定義しています。現時点では、標準の NHibernate で使用できる .hbm.xml を使用しています。
これは、SessionFactory をセットアップする方法です。
private static ISessionFactory CreateSessionFactory()
{
String schemaExportPath = Path.Combine(System.Environment.CurrentDirectory, "Mappings");
if (!Directory.Exists(schemaExportPath))
Directory.CreateDirectory(schemaExportPath);
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c =>c.FromConnectionStringWithKey("connectionString"))
.Cache(c => c.UseQueryCache()
.ProviderClass<HashtableCacheProvider>()).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>().ExportTo(schemaExportPath))
.ExposeConfiguration(c => new SchemaExport(c).SetOutputFile(@"c:\temp\test.sql").Create(false, true))
.BuildSessionFactory();
}