开发者

Fluent Auto Mappings with abstract base also part of model

Ok, firstly I hope this makes sense.

I'm trying to use fluent auto mappings for my app based around the following idea.

public abstract class Container
{
  public virtual int Id {get; set};
  public virtual string Name {get; set;}
}

public class FirstSubClass : Container
{
   //properties and behaviour here
}

public class SecondSubClass : Container
{
  //properties of SecondSubclass Here
}

public class ProcessStep
{
   public virtual Container Source {get; set}
   public virtual Container Destination {get; set;}
}

However, when I try to generate the schema or test my mappings (with SQLite or otherwise) it's failing noting :

NHibernate.MappingException : An association from the table开发者_开发百科 ProcessStep refers to an unmapped class: ......Entities.Container

If I change the Container class and make it none abstract it works.

Can I expose a property on an entity against a base type, with the base remaining abstract?

Any help would be gratefully appreciated.


By default Fluent Nhibernate ignores abstract base classes when generating mappings. To include it you need to use IncludeBase method:

AutoMap.AssemblyOf<Container>(cfg)
       .IncludeBase<Container>();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜