Fluent NHibernate 是否可以同时使用自动映射和模式生成?

发布于 2024-08-06 12:02:35 字数 757 浏览 4 评论 0原文

我正在使用以下内容:

Fluently.Configure()
        .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString))
        .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Incident>()
        .Where(t => t.Namespace.StartsWith("EDA.DomainModel.POCO"))))
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();

它本质上是 Fluent NHibernate wiki 中内容的副本。然而,每当我运行这一行时,它都会抛出这个 InnerException:

"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter."

我真的不确定问题是什么,所以我想知道 Fluent NHibernate 是否可以在第一个中与模式生成一起进行自动映射地方。我想做的只是为 POCO 创建一个持久层,而不必查看数据库或摆弄任何表。

I'm using the following:

Fluently.Configure()
        .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString))
        .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Incident>()
        .Where(t => t.Namespace.StartsWith("EDA.DomainModel.POCO"))))
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();

It's essentially a copy of what's in the Fluent NHibernate wiki. However, whenever I run this line, it throws out this InnerException:

"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter."

I'm really not sure what the problem is, so I'm wondering if Fluent NHibernate can do automapping together with schema generation in the first place. What I want to do is just create a persistence layer for the POCO's without having to see the database or fool around with any tables whatsoever.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

岁月染过的梦 2024-08-13 12:02:35

是的,这是可能的。我使用自动映射并导出架构。至于这个异常,当我尝试映射 IDictionary<,> 时得到了它。你用它吗?即使您不尝试导出模式,Fluent NHibernate 是否还能工作?我想说这是您的映射的问题,而不是模式导出的问题。如果你有 IDictionary 那么几乎可以肯定。尝试将您的模式确定为简单的类,看看是否有帮助;尝试手动创建数据库模式(对于简单的类来说很简单)并检查它是否有效。

Yes it is possible. I use automapping and do export schema. As for that the exception I got it when I tried to map IDictionary<,>. Do you use it? Does Fluent NHibernate work at all - even if you don't try to export schema? I'd say that it's a problem with your mappings, not with schema export. If you have IDictionary then it's almost for sure. Try to nail down your schema to trivial classes and see if it helps; try to create database schema manually (for trivial classes it's simple) and check if it works then.

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