2
我與功能NHibernate以下情況:流利的層次
public class Stuff
{
public Stuff()
{
Entities = new List<Entity>();
}
public virtual int Id { get; set; }
public virtual IList<Entity> Entities { get; set; }
}
public abstract class Entity
{
public virtual int Id { get; set; }
public virtual string Type { get; set; }
public virtual Stuff Stuff { get; set; }
}
public class Person : Entity
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
}
public class Animal : Entity
{
public virtual string Species { get; set; }
}
然後,我有下面的代碼使用自動映射,並生成這些映射:
var sessionFactory =
Fluently.Configure().Database(persistenceConfigurer).Mappings(
m =>
m.AutoMappings.Add(
AutoMap.Source(new Types(typeof(Entity), typeof(Person), typeof(Animal), typeof(Stuff))))
.ExportTo(@"e:\")).ExposeConfiguration(BuildSchema).BuildSessionFactory();
然而
,發生的事情是,我得到以下異常:
---> NHibernate.MappingException:關聯引用未映射的類:ConsoleApplication1.Models.Entity
,如果我做實體類非抽象但是這個作品,我想,以避免在數據庫中的表,但仍維持層次概念,重新