我认为您不需要调试 FluentNhibernate。问题可能出在您的约定中。
据我了解,您有一个对象区域,它被引用到其他对象工作流。因此,为所有参考链接 eq 设置一个约定:
private Action<IConventionFinder> GetConventions()
{
return c =>
{
c.Add<PrimaryKeyConvention>();
c.Add<ReferenceConvention>();
c.Add<HasManyConvention>();
c.Add<TableNameConvention>();
c.Add<PropertyNameConvention>();
};
}
在你的实现中使用这个私有方法
public AutoPersistenceModel Generate()
参考约定应该是这样的:
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;
public class ReferenceConvention : IReferenceConvention
{
public void Apply(IManyToOneInstance instance)
{
instance.Column(Inflector.Net.Inflector.Camelize(instance.Property.Name) + "Id");
}
}
如果是这种情况,还要检查您是否覆盖了映射。
我有一个 unittest 女巫导出映射。不幸的是,下面是旧版本:
[Test, Ignore("Run this test only if you want to see mappings")]
public void ShouldExportMappings()
{
const string mappingPath = @"mappings";
if (!Directory.Exists(mappingPath))
Directory.CreateDirectory(mappingPath);
var sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.Mappings(m =>
{
m.FluentMappings
.AddFromAssemblyOf<User>()
.ExportTo(mappingPath);
m.AutoMappings
.Add(new AutoPersistenceModelGenerator().Generate())
.ExportTo(mappingPath);
}).BuildSessionFactory();
}
最后,如果您真的想调试,请从存储中复制 FluentNHibernate 源并将其包含到您的 sln 中。但这不是一个好主意,因为问题出在您的代码而不是他们的代码中。这无济于事,您只会浪费时间。