我是 NHibernate 的新手,我基于教程: http: //nhibernate.info/doc/tutorials/first-nh-app/your-first-nhibernate-based-application.html。所以我有NHibernateHelper:
public class NHibernateHelper {
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
var configuration = new Configuration();
configuration.Configure();
configuration.AddAssembly(typeof (Product).Assembly);
_sessionFactory = configuration.BuildSessionFactory();
}
return _sessionFactory;
}
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
} }
但我也有实体类别和用户?我是否需要使用代码 AddAssembly 将每个实体添加到配置中?因为当我添加代码时:
configuration.AddAssembly(typeof (Product).Assembly);
configuration.AddAssembly(typeof(Category).Assembly);
我有错误:
无法编译映射文件:MvcApplication1.Mappings.Product.hbm.xml