Fluent nHibernate 配置错误

发布于 2024-11-18 23:28:18 字数 557 浏览 3 评论 0原文

我使用以下代码在我的应用程序中进行 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 技术交流群。

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

发布评论

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

评论(2

星軌x 2024-11-25 23:28:18

这很可能是像马克上面所说的映射问题,但您需要提供更多详细信息。这是如果构建会话工厂失败时抛出的通用外部异常。

try
{
    var FNHConfig = Fluently.Configure()
            .Database(MsSqlConfiguration.MsSql2008
                .ConnectionString(c => c.FromConnectionStringWithKey("FNHConnection"))
                )
                .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetCallingAssembly()))
                .BuildConfiguration();

        return FNHConfig.BuildSessionFactory();
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}

查看控制台窗口中的错误,您很可能会找到此异常的罪魁祸首。

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.

try
{
    var FNHConfig = Fluently.Configure()
            .Database(MsSqlConfiguration.MsSql2008
                .ConnectionString(c => c.FromConnectionStringWithKey("FNHConnection"))
                )
                .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetCallingAssembly()))
                .BuildConfiguration();

        return FNHConfig.BuildSessionFactory();
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}

Take a look at the error in the console window and you will most likely be lead to the culprit of this exception.

傾旎 2024-11-25 23:28:18

如果您深入研究内部异常,它很可能会告诉您问题是什么,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.

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