Fluent NHibernate DuplicateMappingException with AutoMapping

后端 未结 6 1790
终归单人心
终归单人心 2021-01-03 06:08

Summary:

I want to save two classes of the same name and different namespaces with the Fluent NHibernate Automapper

Context

6条回答
  •  星月不相逢
    2021-01-03 06:40

    Use the BeforeBindMapping event to gain access to the object representation of the .HBM XML files.

    This event allows you to modify any properties at runtime before the NHibernate Session Factory is created. This also makes the FluentNHibernate-equivalent convention unnecessary. Unfortunately there is currently no official documentation around this really great feature.

    Here's a global solution to duplicate mapping problems ( Just remember that all HQL queries will now need to use Fully Qualified Type names instead of just the class names ).

    var configuration = new NHibernate.Cfg.Configuration();
    
    configuration.BeforeBindMapping += (sender, args) => args.Mapping.autoimport = false;
    

提交回复
热议问题