BuildSessionFactory 行中的 Automapping 和 FNH 异常

发布于 2024-10-02 13:00:08 字数 165 浏览 0 评论 0原文

我正在使用最新版本的自动映射和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔女人霸气范 2024-10-09 13:00:08

如果它是您不打算映射到数据库的抽象属性,您可能需要在自动映射覆盖中向该属性添加“忽略”。

 mapping.IgnoreProperty(x => x.Description);

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.

 mapping.IgnoreProperty(x => x.Description);
几度春秋 2024-10-09 13:00:08

查看抛出此异常的 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.

匿名的好友 2024-10-09 13:00:08

我遇到了同样的问题,但是当我检查 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文