FluentNHibernate 自动映射“无持久化”
我正在使用最新版本的 Sharp Architecture,并且在对存储库调用 SaveOrUpdate 时遇到问题。我总是收到 MappingException with No persister for: 错误。我没有对默认的 Sharp 架构进行太多更改,并且我指向包含我的实体的 dll。有人遇到过这个问题吗?在我转而使用 Sharp Architecture 之前,它之前就可以使用手动映射。 谢谢!
这是我正在使用的生成函数。 TestEntity 位于从数据项目引用的另一个项目中。如果我为 TestEntity 添加 ClassMap,它会找到映射。
public AutoPersistenceModel Generate()
{
return AutoMap.AssemblyOf<TestEntity>(new AutomappingConfiguration())
.Conventions.Setup(GetConventions())
.IgnoreBase<Entity>()
.IgnoreBase(typeof(EntityWithTypedId<>))
.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
}
I'm using the most recent version of Sharp Architecture, and having problems when I call SaveOrUpdate on a repository. I'm always getting the MappingException with No persister for: error. I haven't changed much from the default Sharp Architecture, and I'm pointing towards the dll that contains my entities. Has anyone run into this problem? It was working before with manual mappings before I switched to using Sharp Architecture.
Thanks!
Here is the generation function I'm using. TestEntity is in another project that is referenced from the data project. If I add a ClassMap for TestEntity, it finds the mapping.
public AutoPersistenceModel Generate()
{
return AutoMap.AssemblyOf<TestEntity>(new AutomappingConfiguration())
.Conventions.Setup(GetConventions())
.IgnoreBase<Entity>()
.IgnoreBase(typeof(EntityWithTypedId<>))
.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此错误消息表明您正在尝试保存未映射的实体。 Sharp Architecture 有一个扩展方法,允许您将所有映射保存为 XML 文件。尝试使用它并检查哪些实体已真正被映射。
This error message indicates that you are trying to save unmapped entity. Sharp Architecture has an extension method that allows you to save all the mappings as XML files. Try to use it and check what entities have really being mapped.
我猜我的自动映射配置将其过滤掉 - 一旦我从 Entity 派生出 TestEntity,自动映射器就会拾取它。
I guess my automapping configuration was filtering it out - once I derived my TestEntity from Entity, the automapper picked it up.