C#/ Postgres / FluentNHibernate:配置npgsql抛出NotSupportedException [英] C# / Postgres / FluentNHibernate : configuring npgsql throws NotSupportedException

查看:180
本文介绍了C#/ Postgres / FluentNHibernate:配置npgsql抛出NotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我真的开始想知道在我的源代码中发生了什么:
我试图使用npgsql 2.0.11.0连接到PostgreSQL 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();

Stacktrace看起来很整齐:只有一行。

 在NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection连接)在d:\CSharp\NH\\\
hibernate\src\NHibernate\Dialect\\ \\ Dialect.cs:第718行。

我试着把这个转换成下面的代码:

  ISessionFactory sf = Fluenly.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();

结果仍然如此。任何人都有类似的问题,甚至更好的解决方案吗?解决方案

我想我最终会拿最多的记录自我回答的问题。

它需要将hbm2ddl.keywords属性设置为none。现在它像一个魅力。
干杯!

$ $ $ $ $ $ $ $ $数据库(PostgreSQLConfiguration.PostgreSQL82
.Raw(hbm2ddl.keywords,没有));


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?

解决方案

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!

 .Database(PostgreSQLConfiguration.PostgreSQL82
                        .Raw("hbm2ddl.keywords","none"));

这篇关于C#/ Postgres / FluentNHibernate:配置npgsql抛出NotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆