Fluent nHibernate 配置错误
我使用以下代码在我的应用程序中进行 Fluent nHibernate 的配置,
var FNHConfig = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("FNHConnection"))
)
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetCallingAssembly()))
.BuildConfiguration();
return FNHConfig.BuildSessionFactory();
但它给出了异常:“创建 SessionFactory 时使用了无效或不完整的配置。”。有人知道如何解决这个异常吗?
谢谢
i m doing the configuration of Fluent nHibernate in my application with the following code ,
var FNHConfig = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("FNHConnection"))
)
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetCallingAssembly()))
.BuildConfiguration();
return FNHConfig.BuildSessionFactory();
but it giving exception saying that "An invalid or incomplete configuration was used while creating a SessionFactory. ". anyone have idea how to solve this exception ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很可能是像马克上面所说的映射问题,但您需要提供更多详细信息。这是如果构建会话工厂失败时抛出的通用外部异常。
查看控制台窗口中的错误,您很可能会找到此异常的罪魁祸首。
It's most likely a mapping problem like Mark says above but you need to provide more detail. That is the generic outer exception that is thrown if you fail to build the Session Factory.
Take a look at the error in the console window and you will most likely be lead to the culprit of this exception.
如果您深入研究内部异常,它很可能会告诉您问题是什么,NH3.X 有相当不错的异常消息。
我会在黑暗中捅一刀,说你没有将对象上的所有公共属性、方法和事件标记为
虚拟
。您可以发布您的业务对象和映射类吗?
If you dive into the inner exception it will most likely tell you what the issue is, NH3.X has pretty decent exception messages.
I'll take a stab in the dark and say that you haven't marked all the public Properties, Methods and Events on your object as
virtual
.Can you post your Business Objects and Mapping Classes.