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));
精彩评论