Well, your problem isn't just a fluent issue, so you'll want to follow one of these<http://codebetter.com/blogs/karlseguin/archive/2009/03/30/using-nhibernate-with-multiple-databases.aspx> articles. <http://www.codeproject.com/KB/aspnet/NHibernateMultipleDBs.aspx> Managing multiple databases and persisting between them seamlessly in the same session, to my knowledge, is a difficult task ;) . You probably don't want to use two configurations, you would use one configuration (and you can pass it to the Fluently.Configure(yourConfiguration) call in order to build your mappings on different assemblies) and two session factories.
I have no practical experience doing something like this, so it's possible there's another, better, alternative. On Thu, Apr 23, 2009 at 12:07 PM, David R. Longnecker < [email protected]> wrote: > After a day of beating the desk, I figured I'd toss this out and see where > I've gone astray. :) > > I have two fluent configurations... one to our primary business application > that contains a mapping to an object (a "school" object) and a second that > is for a secondary system I'm developing that needs to create a list of > objects based on the mapping from that primary app. > > In the entity object "BuildingUser": > > public virtual IList<School> BuildingUserSchools { get; set; } > > School is part of another database; that database is being initialized > prior to this secondary database, so the mapping files for "School" should > be available. > > In the BuildingUserMap file: > > HasManyToMany(x => x.BuildingUserSchools) > .WithTableName("BuildingUserSchools") > .WithParentKeyColumn("Id") > .WithChildKeyColumn("BuildingUserId") > .FetchType.Join(); > > I've tried explicitly setting ".CollectionType(typeof (School))" to no > avail. It seems there should be a property to say "when building a school > object, you need to know the BuildingUserSchools.SchoolId column..." > > When initializing the fluent configuration, the mappings are using standard > fluent mappings: > > .Mappings(mappings => mappings > .FluentMappings > .AddFromAssemblyOf<AssessmentMap>()); > > Trying to init that configuration, however, returns the following error: > > "An association from the table BuildingUserSchools refers to an unmapped > class: USD259.Domain.Sis.School" > > As I mentioned prior, the fluent configuration that maps > USD259.Domain.Sis.School is initializing just fine; I can return School > objects without any issues; however, it seems the second "Assessment" > configuration isn't aware that the first exists. > > So the question: Is there a way to tell one fluent configuration that > another, already initialized mapping configuration is available and to use > it's mappings for objects? e.g. > > (fluent config #1) NewApplication.Assessment.BuildingUserSchools > > is a > > (fluent config #2) IList<USD259.Domain.Sis.School> > > I keep having this sinking feeling that for each of the fluent mappings to > be "aware" of each other, they each have to map each other... > > Is there a better way to do this? > > Thanks in advance! > > -dl > > David R. Longnecker > Blog <http://blog.tiredstudent.com/> | > Twitter<http://www.twitter.com/dlongnecker>| > LinkedIn <http://www.linkedin.com/in/davidlongnecker> > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
