FluentNHibernate - ClassMap vs IAutoMappingOverride

In FluentNHibernate, when should I use ClassMap and IAutoMappingOverride<Entity> for my EntityMap classes.


 public class PostMap : ClassMap<Post> { public PostMap() { ... } } 

against

 public class PostMap : IAutoMappingOverride<Post> { public void Override(AutoMapping<Post> mapping) { ... } } 
+4
source share
1 answer

ClassMaps are used when matching objects manually. In this case, you create a separate ClassMap for each object that indicates how this object maps to the database.

IAutoMappingOverrides are used when matching objects using AutoMapping. When using AutoMapping Fluent, NHibernate tries to automatically determine how objects should be mapped to the database, but sometimes automatically generated mappings are not quite what you wanted, so you need to override those parts that need to be configured. In this case, you create a display override for each object that needs to override automatic matching and override only those parts.

More information can be found on the Fluent NHibernate wiki:

+10
source

Source: https://habr.com/ru/post/1307910/


All Articles