尝试运行 Fluent NHibernate 教程示例时出错
我已经下载了 Fluent NHibernate 源代码发行版,编译了解决方案中的所有项目,然后运行 Examples.FirstProject。 FluentConfiguration.cs 中的方法 BuildSessionFactory() 中发生异常:创建 SessionFactory 时使用了无效或不完整的配置。我该怎么做才能避免这种异常?
PS我看到这篇文章但它不是帮我
编辑: 异常消息“以下类型不得用作代理:\nExamples.FirstProject.Entities.Employee:方法 set_Id 应为“公共/受保护的虚拟”或“受保护的内部虚拟”\nExamples.FirstProject。 Entities.Product:方法 set_Id 应为“公共/受保护的虚拟”或“受保护的内部虚拟”\nExamples.FirstProject.Entities.Store:方法 set_Id 应为'公共/受保护的虚拟'或'受保护的内部虚拟'"字符串
异常源:“NHibernate”
异常StackTrace: StackTrace 位于 d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs 中的 NHibernate.Cfg.Configuration.ValidateEntities():第 1051 行\r\n 位于 NHibernate.Cfg.Configuration.Validate()在d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:第 958 行\r\n 位于 d:\CSharp\NH\NH\nhibernate\src 中的 NHibernate.Cfg.Configuration.BuildSessionFactory() \NHibernate\Cfg\Configuration.cs:第 1250 行\r\n 位于FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() 在 C:\_WorkProjects\_nHibernate\jagregory-fluent-nhibernate-c24de5a\src\FluentNHibernate\Cfg\FluentConfiguration.cs:第 231 行“字符串
I have downloaded the Fluent NHibernate source distribution, compiled all projects in solution and then run Examples.FirstProject. Exception occur in FluentConfiguration.cs in method BuildSessionFactory(): An invalid or incomplete configuration was used while creating a SessionFactory. What shall I do to avoid this exception?
PS I saw this post but its not help me
Edit:
Exception Message "The following types may not be used as proxies:\nExamples.FirstProject.Entities.Employee: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Product: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Store: method set_Id should be 'public/protected virtual' or 'protected internal virtual'" string
Exception Source: "NHibernate"
Exception StackTrace:
StackTrace " at NHibernate.Cfg.Configuration.ValidateEntities() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1051\r\n at NHibernate.Cfg.Configuration.Validate() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 958\r\n at NHibernate.Cfg.Configuration.BuildSessionFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1250\r\n at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in C:\_WorkProjects\_nHibernate\jagregory-fluent-nhibernate-c24de5a\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 231" string
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
转到 (Examples.FirstProject -> Entities -> 并在 (Employee.cs、Product.cs 和 Store.cs)
中将 Id 属性从: 更改
为:
Go to (Examples.FirstProject -> Entities -> and in (Employee.cs, Product.cs, and Store.cs)
Change the Id property from:
To:
您的类型 Examples.FirstProject.Entities.Employee 应将 ID 属性设置为
Your type, Examples.FirstProject.Entities.Employee should have the ID property set to