I have one assembly for mappings totally separated from my domain entities.
In the fluent configuration I just do AddFromAssemblyOf<*DomainEntityMap*>
and that takes care of the mappings. If this does not work then I am pretty
certain that there is either a problem with the reference or a problem with
the mapping.

On Wed, Sep 23, 2009 at 4:16 PM, Mark Phillips <[email protected]>wrote:

>
> Hi Paul,
>
>  I guess nothing is obvious to me at this point.  I'm hoping to learn
> the way Fluent NHibernate works and its restrictions.
>
> With XML configuration,  you could have your domain model in one
> assembly and configure your mappings from a different assembly.
>
> It appears from my experimentation that with Fluent NHibernate, the
> mappings have to be in the same assembly as the domain model.  At
> least, I've been unable to get it to work any other way.  (This may be
> where I am making a mistake). But when I look at this method chain:
>
>              m.FluentMappings.AddFromAssembyOf<T>
> ().Conventions.AddFromAssemblyOf<T>()
>
>  the words "AddFromAssemblyOf<T>"  mean that I can choose which
> assembly contains my domain model and which contains my mappings.  And
> that if I have referenced my domain model assembly in my mapping
> assemby that Fluent NHibernate would use reflection to interogate the
> referenced domain model  assembly in order to create mappings.
>
> So after my long winded explanation, let me ask these questions more
> succinctly?
>
> 1a)  Does the use of ClassMap have to be in the same assembly as the
> Domain Model?
> 1b)  If not, how do I separate the two, cause I am failing when I try.
>
> Thanks for your time!
>
> Mark
>
>
>
> On Sep 23, 3:27 am, Paul Batum <[email protected]> wrote:
> > Is the code you've included what you are trying to get working or what
> > you've fallen back to?
> > I ask because you are trying to load your fluent mappings from your
> domain
> > assembly with this line:
> >    m.FluentMappings.AddFromAssemblyOf<Employee>()
> > If you move your fluent mappings out from the domain assembly then
> obviously
> > this line won't work.
> >
> > On Wed, Sep 23, 2009 at 6:31 AM, Mark Phillips <[email protected]
> >wrote:
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I am attempting to use FNH in an application that has 3 major layers:
> >
> > > DomainModel,
> > > Infrastructure,
> > > TestProject
> >
> > >  If I place the mappings in the Infrastructure assembly, the code does
> > > not blowup, but it also does not generate the database schema.  The
> > > database schema is only generated when the mappings are in the same
> > > project as the DomainModel.  Is there a solution to this?  Is this a
> > > current limitation or did I miss something?  I would have thought that
> > > calls to "AddFromAssemblyOf<T>" would make the mappings assembly
> > > independent.
> >
> > > Thanks,
> > > Mark
> >
> > > Here is what I am using:
> >
> > > public static ISessionFactory CreateSessionFactory() {
> > >            string connectionString =
> >
> > > System.Configuration.ConfigurationManager.ConnectionStrings
> > > ["StoreConnection"].ConnectionString;
> >
> > >            return Fluently.Configure()
> > >                .Database(MsSqlConfiguration.MsSql2005
> > >                    .ConnectionString(c => c.Is(connectionString))
> > >                )
> > >                .Mappings(m => {
> > >                    m.FluentMappings.AddFromAssemblyOf<Employee>()
> > >                        .Conventions.AddFromAssemblyOf<StoreMap>()
> > >                        .ExportTo(@"C:\Documents and Settings\Mark\"
> > >                })
> > >               .ExposeConfiguration(BuildSchema)
> > >               .BuildSessionFactory();
> > > }
> >
> > > private static void BuildSchema(Configuration config) {
> > >            new SchemaExport(config).Create(true, true);
> > > }- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to