我正在尝试将 FluentNHibernate 与 Automapping 结合使用,但收到以下错误
No persister for: nHibernateSpike.Entities.Route
NHibernate.MappingException: No persister for: nHibernateSpike.Entities.Route
这是相关的东西;
var model = AutoMap.AssemblyOf<Route>().
Where(t => t.Namespace == "nHibernateSpike.Entities");
model.WriteMappingsTo(@"c:\hbm");
var db = MsSqlConfiguration.MsSql2008
.ConnectionString(c => c
.Server("localhost")
.Database("PTSIntegrationDB")
.TrustedConnection()
)
.ShowSql();
var sessionFactory = Fluently.Configure()
.Database( db )
//.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Route>())
.Mappings(m => m.AutoMappings.Add(model))
.BuildSessionFactory();
return sessionFactory;
实体
namespace nHibernateSpike.Entities
{
public class Route
{
public virtual int Id { get; private set; }
public virtual string Number { get; set; }
public virtual string ConfirmationCategory { get; set; }
public Route() { }
}
}
我正在拔头发。使用以下 ClassMap 有效;
public class RouteMap: ClassMap<Route>
{
public RouteMap()
{
Table("Route");
Id(c => c.Id);
Map(c => c.Number);
Map(c => c.ConfirmationCategory);
}
}
我有机会在这个项目中使用 AutoMap 来驱动数据库,我想使用它 - 有什么线索吗?