[Mono-aspnet-list] FluentNHibernate InvalidCastException at creating SessionFactory

gajcz gajczewski at gmail.com
Fri Aug 26 11:01:56 EDT 2011


Ok, it seems I resolved this problem by myself. This is what I found (maybe
it will help someone):

Going deeper to NHibernate sources I noticed that only when
*setting.IsKeywordsImportEnabled* is set the crashing part is fired
(SchemaMetadataUpdater.Update(this)).
There the SuppliedConnectionProviderConnectionHelper tries to cast some type
to DbConnection, this type is probably NpgsqlConnection class which doesn't
derive from DbConnection, however it implements IDbConnection.

How to disable IsKeywordImportEnabled?

sessionFactory = Fluently.Configure() 
                .Database(databaseConfiguration) 
                .Mappings(m => 
                    { 
                       
m.FluentMappings.AddFromAssemblyOf<Models.MyClass>(); 
                    }) 
                *.ExposeConfiguration(c =>
                    {
                        c.SetProperty(Environment.Hbm2ddlKeyWords, "none");
                    })*
                .BuildSessionFactory();

Actually I don't know what this setting will cause, but retrieving and
inserting entities seem to work fine.

--
View this message in context: http://mono.1490590.n4.nabble.com/FluentNHibernate-InvalidCastException-at-creating-SessionFactory-tp3770661p3771120.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.


More information about the Mono-aspnet-list mailing list