NHibernate.MappingException: No persister for: XYZ

后端 未结 16 1064
天命终不由人
天命终不由人 2020-12-01 03:24

Now, before you say it: I did Google and my hbm.xml file is an Embedded Resource.

Here is the code I am calling:

相关标签:
16条回答
  • 2020-12-01 04:01

    Something obvious, yet quite useful for someone new to NHibernate.

    All XML Mapping files should be treated as Embedded Resources rather than the default Content. This option is set by editing the Build Action attribute in the file's properties.

    XML files are then embedded into the assembly, and parsed at project startup during NHibernate's configuration phase.

    0 讨论(0)
  • 2020-12-01 04:01

    Don't forget to specify mapping information in .config file

    e.g.

    where MyApp.Data is assembly that contains your mappings

    0 讨论(0)
  • 2020-12-01 04:02

    My issue was that I forgot to put the .hbm in the name of the mapping xml. Also make sure you make it an embedded resource!

    0 讨论(0)
  • 2020-12-01 04:03

    To add to Amol's answer, don't make the mistake of specifying the Interface class type. Make sure you specify the implementation class. (Ie. don't use IDomainObjectType). Not that I made this mistake... :)

    0 讨论(0)
提交回复
热议问题