重新DBContext中OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//取基类=EntityBase
var entityTypes = Assembly.GetEntryAssembly().GetTypes()
.Where(type => !String.IsNullOrEmpty(type.Namespace))
.Where(type => type.GetTypeInfo().BaseType != null && type.GetTypeInfo().BaseType == typeof(EntityBase)); foreach (var type in entityTypes)
{
modelBuilder.Model.GetOrAddEntityType(type);
}
base.OnModelCreating(modelBuilder);
}