我在我的域中添加了一个新类,但这次流畅地不会映射到数据库
这是班级
namespace FClinic.Domain.Entities.Tenants
{
using System;
using Core;
public class Tenant : BaseTenant
{
public virtual DateTime UsageUntil { get; set; }
}
public abstract class BaseTenant : Entity
{
public virtual string Name { get; set; }
public virtual string Key { get; set; }
}
}
流利的配置就是这个:
public class FclinicConfiguration : DefaultAutomappingConfiguration
{
public override bool ShouldMap(Type type)
{
if (type.Name.Contains("<>c__DisplayClass"))
return false;
if (type.Name == "CancelationResult")
return false;
return type.Namespace != null && type.Namespace.StartsWith("FClinic.Domain.Entities") && !type.IsValueType;
}
public override bool ShouldMap(FluentNHibernate.Member member)
{
if (!member.CanWrite)
return false;
return base.ShouldMap(member);
}
public override bool IsComponent(Type type)
{
if (type == typeof(ContactoEmergencia))
{
return true;
}
return base.IsComponent(type);
}
}
您可以看到租户实体名称空间以“FClinic.Domain.Entities”开头并与其他条件匹配
type.Namespace != null
&& type.Namespace.StartsWith("FClinic.Domain.Entities")
&& !type.IsValueType;
实际上,方法ShouldMap(Type type)对Tenant Type返回true,但是当我检查生成的Database时,它包括除了这个之外的所有其他类
任何想法?
流利配置
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(config.ConnectionString))
.Mappings(m => m.AutoMappings
.Add(AutoMap.AssemblyOf<Administrador>(new FclinicConfiguration())
.UseOverridesFromAssemblyOf<UsuarioMappingOverride>()
.IncludeBase<TreatmentBaseTemplate>()
.Conventions.Add<GuidIdentity>()
.Conventions.Add<ForeignKeyNameConvention>()
.Conventions.Add<ReferenceConvention>()
.Conventions.Add<DecimalConvention>()))
.ExposeConfiguration(c => new SchemaUpdate(c).Execute(false, true))
.BuildSessionFactory();