Setting the sessionfactory name using fnh
Hi,
Is there no way to set the SessionFactory's name using Fluent NHibernate? If not, is there a way to export that part of the NH configuration? I couldn't find a way to do this either.
Thanks
Hi,
Is there no way to set the SessionFactory's name using Fluent NHibernate? If not, is there a way to export that part of the NH configuration? I couldn't find a way to do this either.
Thanks
Support Staff 2 Posted by Paul Batum on 15 Sep, 2010 04:57 PM
You can always use the normal nhibernate supported ways of providing your
configuration. Your not limited to what our fluent interface offers.
From our wiki (http://wiki.fluentnhibernate.org/Database_configuration) :
Using Fluent NHibernate does not require you to sacrifice portability across
RDBMSes. You can use the traditional approach to NHibernate configuration
(which uses the standard .NET configuration mechanisms) to determine
database drivers and connection strings this way:
var cfg = new NHibernate.Cfg.Configuration();
cfg.Configure(); // read config default style
Fluently.Configure(cfg)
.Mappings(
m => m.FluentMappings.AddFromAssemblyOf<Entity>())
.BuildSessionFactory();
On Mon, Sep 13, 2010 at 7:08 AM, He Zhu <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote:
3 Posted by He Zhu on 15 Sep, 2010 09:08 PM
Fantastic! Just the thing I was looking for. Completely missed that section of the wiki xD
Thanks a lot.
4 Posted by He Zhu on 16 Sep, 2010 08:52 AM
Hi, just a heads up:
I used the following code to set the session factory name but it didn't work. The NH cfg recognises the name but after I passed it to Fluently.Configure, the resulting factory has Name null. I dug around and found the property is called "session_factory_name" and used ExposeConfiguration SetProperty to get around it.
Is this a bug?
hibernate.cfg.xml
` <?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
</hibernate-configuration>
`
code
` var cfg = new NHibernate.Cfg.Configuration();
cfg.Configure();
return Fluently.Configure(cfg)
`
Support Staff 5 Posted by Paul Batum on 19 Sep, 2010 01:55 AM
Oh I didn't realise that we had a way to set the session factory name from
our fluent interface. I had a quick look beforehand and failed to find it.
It does seem somewhat undesirable that we might overwrite someone's config
setting with our own blank one. I wonder if this is an isolated bug or if
this is happening with other configuration settings as well...
On Thu, Sep 16, 2010 at 1:55 AM, He Zhu <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote: