C# / Postgres / FluentNHibernate:配置 npgsql 抛出 NotSupportedException
有时我真的开始想知道我的源代码中发生了什么: 我正在尝试使用 npgsql 2.0.11.0 连接到 PostGres 9.0,我确信我已经这样做了,但是现在,我的程序在进入以下步骤时抛出 NotSupportedException
ISessionFactory sf = Fluently.Configure()
.Database(PostgreSQLConfiguration.PostgreSQL82
.ConnectionString(c => c
.Host("localhost")
.Port(5432)
.Database("cw")
.Username("cw")
.Password("mypass")))
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<MyMapping>())
.BuildSessionFactory();
:看起来很简洁:只有一行。
at NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection) in d:\CSharp\NH\nhibernate\src\NHibernate\Dialect\Dialect.cs:Line 718.
我尝试将其转录为以下内容:
ISessionFactory sf = Fluently.Configure()
.Database(PostgreSQLConfiguration.PostgreSQL82
.ConnectionString(c => c.Is("Server=localhost;Port=5432;Database=cw;User Id=cw;Password=myPass;")))
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<CardTemplateMapping>())
.BuildSessionFactory();
尽管如此,结果是相同的。有人遇到过类似的问题,或者更好的是有解决办法吗?
Sometimes I really start wondering what's going on in my sourcecode:
I'm trying to connect to PostGres 9.0 using npgsql 2.0.11.0, which I'm damn sure I already did, but right now, my program throws a NotSupportedException as it steps into the following :
ISessionFactory sf = Fluently.Configure()
.Database(PostgreSQLConfiguration.PostgreSQL82
.ConnectionString(c => c
.Host("localhost")
.Port(5432)
.Database("cw")
.Username("cw")
.Password("mypass")))
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<MyMapping>())
.BuildSessionFactory();
The Stacktrace is quite neat to look at: Just one line.
at NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection) in d:\CSharp\NH\nhibernate\src\NHibernate\Dialect\Dialect.cs:Line 718.
I tried transcribing this to the following:
ISessionFactory sf = Fluently.Configure()
.Database(PostgreSQLConfiguration.PostgreSQL82
.ConnectionString(c => c.Is("Server=localhost;Port=5432;Database=cw;User Id=cw;Password=myPass;")))
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<CardTemplateMapping>())
.BuildSessionFactory();
Still, the result's the same. Anybody had similar issues or - even better - a fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我最终会保持自我回答问题最多的记录。
它需要将 hbm2ddl.keywords 属性设置为 none。现在它就像一个魅力。
干杯!
I guess I'll end up holding a record for the most self-answered questions.
It needed the hbm2ddl.keywords property set to none. Now it works like a charm.
Cheers!
看到你已经找到了解决方案。因此,仅提供一些背景知识:
“none”将禁用有关 RDBMS 关键字的任何操作。
关键字可用于 MsSQL、Oracle、Firebird、MsSqlCe、MySQL、SQLite、SybaseAnywhere。
由于 Postgress 不在列表中,因此必须将其设置为 None。
这里有一些信息:用 NHibernate 和 PostgreSQL 引用列名
See that you already found a solution. So just for some background:
The "none" will disable any operation regarding RDBMS KeyWords.
And the Keywords is available for MsSQL, Oracle, Firebird, MsSqlCe, MySQL, SQLite, SybaseAnywhere.
Since Postgress is not in the list it has to be set to None.
There is som info on it here: Quoting column names with NHibernate and PostgreSQL