Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# / Postgres / FluentNHibernate : configuring npgsql throws NotSupportedException

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?

like image 961
Sebastian Edelmeier Avatar asked Mar 05 '26 22:03

Sebastian Edelmeier


1 Answers

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"));
like image 85
Sebastian Edelmeier Avatar answered Mar 08 '26 10:03

Sebastian Edelmeier