views:

82

answers:

2

I need to use ClassMaps instead of auto mapping because of legacy database. But I don't see how to tune SharpArch to use them. I tried to remove AutoPersistentModelGenerator and use the following code in the InitializeNHibernateSession method:

       var config = NHibernateSession.Init(webSessionStorage,
                              new[]{"ApplicationConfiguration.Models.dll"});

       Fluently.Configure(config)
           .Mappings(m =>
                         {   
                             m.FluentMappings.AddFromAssemblyOf<ConfigSchema>();
                         });

But I always get MappingException - "No persister for: ConfigSchema" when trying to work with the ConfigSchema.

Has anyone tried to do this?

Edit:
ConfigSchema is a part of domain model.

A: 

I'm not all that familiar with the S#arp project, but is ConfigSchema a type from you domain model? The generic argument T to AddFromAssemblyOf<T> should be a mapped class from your domain model.

Jamie Ide
Yes, it's part of domain model.
zihotki
+1  A: 

I'm stupid. Fluently.Configure(config) generates a new config for NHibernate. So it will never be used in my scenario. All I was need is to use the following code in the AutoPersistentModelGenerator:

    public AutoPersistenceModel Generate()
    {
        var mappings = new AutoPersistenceModel();

        mappings.AddMappingsFromAssembly(typeof(ConfigVersionMap).Assembly);

        return mappings;
    }
zihotki