Fluent NHibernate 是否可以同时使用自动映射和模式生成?
我正在使用以下内容:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的。我使用自动映射并导出架构。至于这个异常,当我尝试映射 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.