Question: I have an annoying problem with nhibernate.
The problem is I cannot get any example I find on the web to work...
I've now tried for two days...
The first problem was it wouldn't read the config file, so I had to move it into app.config / web.config.
The second problem is that whatever I do, I always get an error:
No persister for: NHibernate.Examples.QuickStart.User
I've searched google and I did change the mapping to embeded ressource, and I did add the mapping to the config file, but nothing helps...
The example is from this page:
I've uploaded my Visual Studio 2005 project to
Does anybody know what I do wrong ?
Here's everything I had to fix to get your code working:
Configuration.LoadMappingDocumentonly validates the mapping, but does not add it to the configuration, i.e. it works as documented. It should probably have a better name (like
ValidateMappingor something). Use
AddDocumentor similar instead, though I recommend using
AddAssemblyand having the mapping embedded as a resource;
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples"the part after the comma is the assembly name. It should be
<class name="NHibernate.Examples.QuickStart.User, NHibernateCrap", or you should change the assembly name (I'd recommend that);
For further learning I recommend you read Gabriel Schenker's NHibernate tutorials.