开发者

How do I exclude a base class using fluent mappings in Fluent NHibernate?

开发者 https://www.devze.com 2022-12-12 16:54 出处:网络
I have an abstract base class, Entity, that all my POCOs derive from: public abstract class Entity { public virtual Guid Id { get; set; }

I have an abstract base class, Entity, that all my POCOs derive from:

public abstract class Entity
{
    public virtual Guid Id { get; set; }
}

And the mapping file:

public class EntityMap<T> : ClassMap<T> where T : Entity
{
    public EntityMap
    {
        Id(x => x.Id);
    }
}

This way, I don't have to write Id(x =>开发者_JAVA技巧 x.Id) in every mapping file by using this:

public class Something : EntityMap<T>
{
    blahblah
}

I'm auto-generating my database schema, and everything looks fine, except that the Entity base class is added as a table. Using fluent mappings, how do I configure it so that the Entity class is excluded from the database schema?


You can add it to the ignore list of auto mapper:

AutoMap.AssemblyOf<Entity>()
  .IgnoreBase(typeof(Entity));
0

精彩评论

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