簡體   English   中英

C#/ Postgres / FluentNHibernate:配置npgsql拋出NotSupportedException

[英]C# / Postgres / FluentNHibernate : configuring npgsql throws 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();

Stacktrace看起來很整潔:僅一行。

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();

盡管如此,結果還是一樣。 任何人都有類似的問題,或者甚至更好的解決方法?

我猜我最終將保留最回答的問題的記錄。

需要將hbm2ddl.keywords屬性設置為none。 現在它就像一個魅力。 干杯!

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

看到您已經找到了解決方案。 因此,僅出於某些背景:

“無”將禁用有關RDBMS關鍵字的任何操作。

並且關鍵字可用於MsSQL,Oracle,Firebird,MsSqlCe,MySQL,SQLite,SybaseAnywhere。

由於Postgress不在列表中,因此必須將其設置為None。

這里有som信息: 用NHibernate和PostgreSQL引用列名

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM