After creating a new mapping file using the code mapping feature in NHibernate, it didn’t work when I tried to persist an instance of the object. Instead I got the following error message:
NHibernate.MappingException: No persister for: Sample.Product
Here is the mapping file I’m using:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductMapping: ClassMapping<Product> | |
{ | |
public ProductMapping() | |
{ | |
Table("Product"); | |
Property(x => x.Description); | |
Property(x => x.Category); | |
Property(x => x.Price); | |
} | |
} |
Do you notice what’s wrong? ….
I forgot to make my mapping class public:
public class ProductMapping: ClassMapping<Product>