BuildSessionFactory 行中的 Automapping 和 FNH 异常
我正在使用最新版本的自动映射和 FNH 与 vs2008,我得到了这个异常 “已添加属性“描述”时尝试添加”
,该异常不提供任何信息!我无法找出哪个类导致此错误。
其次,我该如何解决这个问题?是因为我有一个抽象的“描述”属性吗?
i am using the latest version of automapping and FNH with vs2008, i got this exception
"Tried to add property 'Description' when already added"
first , the exception is not informative! i cannot find out which class cause this error.
secondly, how can i solve this problem ? is it because of an abstract 'description' property i have ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它是您不打算映射到数据库的抽象属性,您可能需要在自动映射覆盖中向该属性添加“忽略”。
If it's an abstract property that you don't intend to map to the database you might want to add an Ignore to that property in your automapping override.
查看抛出此异常的 FluentNHibernate 代码 建议您可能在类映射中调用 Map(x => x.Description) 两次。
Looking at the FluentNHibernate code that throws this exception suggests that you might be calling Map(x => x.Description) twice in your class map.
我遇到了同样的问题,但是当我检查 Map 类时,我发现由于某种原因,代码生成器放置了同一属性的两个实例,因此在运行时抛出了此异常。
作为检查列表,请检查实体映射类的映射文件,并确保映射对于属性是唯一的。
一旦我删除了重复的,我就可以运行它。
谢谢
I had the same issue but when i checked the Map class i found out for some reason the code generator has put two instance of the same property as a result in run time this exception was thrown.
As a check list please check your Map file of the entity map class and make sure the mapping is unique to property.
I was able run it once i removed the duplicate one.
thanks