"No persister for: X.Domain.Person" Nhibernate Error - nhibernate

in My nhibernate.cfg.xml file I have
<mapping assembly="X.Domain" />
Which would usually works - Inside My X.Domain I have my Fluent Mappings. in which I have tests to verify all the mappings are set up correctly. Not sure if this is because I am using Fluent in my Domain Layer and nhiberante.cfg.xml in my MVC project.
Any ideas

The <mapping/> element is part of NH core; it only recognizes hbm.xml files built as embedded resources, not fluent mappings.

Related

NopCommerece => Moving Mapping folder of Data Access Layer in Seperate Project

In NopCommerece MVC version, I am trying to move the mapping folder out of the DAL project to a seperate class library project, I am trying it to make the DAL more generic, so that it can be used in other projects as well.
But when I run the application, for every entity it says that "The entity type [EntityName] is not part of the model for the current context."
I think its happening because autofac is not finding IRepository for injection, any tips or ideas that where and what I am doing wrong?
Thanks in advance
OK! I found the solution to this issue, in the ObjectContext file, there is an overridden method named OnModelCreating, which was basically creating instances of mapping type objects in the assembly through reflection.
I have asked this method to look into a specific dll for those mapping entries and it started working.

Can I see nhibernate automapper mappings

Automapping in Nhibernate has been this wonderful magical thing, but now something strange is happening and I want to peel back this magical layer and see the actual mappings that are getting generated.
Is there a way to see the mappings generated by automapper and my overrides so I can see if it's doing what I think it's doing?
If you are using Fluent then you should be able to write the persistence model to the disk:
// In your fluent config code
// assuming config is of type FluentNHibernate.Cfg.FluentConfiguration
var model = new FluentNHibernate.PersistenceModel();
config.Mappings(m => m.UsePersistenceModel(model));
model.WriteMappingsTo(#"C:\some_folder_name_for_hbm_files_to_go_into");

NH 3.2 Fluent Mapping Lazy Loading

I used NH 3.2 mapping by code and I tryied Nhibernate Mapping Generator http://nmg.codeplex.com/ which looked a great tool.
I found a big difference between my code and theirs. On each class they have a call to the function LazyLoad(). (Although I thinked that it was the default behaviour)
Now I fear that my application doesn't use lazy loading, does someone know the default behaviour of nh 3.2 with mapping by code ? (when we don't call the LazyLoad method)
Regards
Depends on the default-lazy attribute of the hibernate-mapping tag which can be changed in Fluent NHibernate by adding the DefaultLazy.Always() or DefaultLazy.Never() convention.
If no default-lazy attribute is defined (no convention added in Fluent NHibernate), lazy loading is enabled.

nhibernate export hibernate.cfg.xml when configured by code

How can I export the hibernate.cfg.xml from the nhibernate configuration. I have configured nhibernate in code instead of importing the cfg.xml. I now have a need to export the cfg and the mapping xml files for import into other nhibernate tools. I found a way to export the mapping.xml but fail to find a method to export the cfg.
NHibernate 3.2
I doubt there is an easy way how to do it. NHibernate.Cfg.Configuration does not contains any reference to NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration class which conforms to nhibernate-configuration-2.2 xml schema. You could try to infer all properties of HibernateConfiguration class from Configuration instance by your own.
NHibernate.Cfg.Configuration itself is serializable but it is serialized into quite different schema.
IMO fallback to traditional cfg.xml file would be far easier solution.

NHibernate enum mapping

Can anybody tell me how to map enum in nhibernate using vb.net.When i search the google i found all samples in c# but i want vb.net(i am new to vb.net)
Thanks
Are you using Fluent NHibernate? If not, the XML mappings are identical.
Just create a property node in your xml mapping file which which has the same name as the Property itself. NHibernate will pick up the type (in that case the enum) automatically using reflection.
<property name="YourEnumPropertyName" />