This is a sample project where I have added below things:
- Simple NHiberanate uses.
- Repository Pattern using NHibernate.
- Test Project to test all samples
- Using DI to inject Session object
Please create a database named as "NDemo" inside the SQL Server. I have used SQL2012 express edision.
- Database has to be created manually.
- Fluent API can be written to do Mapping install (FluentNHibernate version="1.4.0.0" targetFramework="net35" )
- Tables can be generated by Code First & Fluent APIs.
- Each complex type must have its own Mapper for reusability or it can be merged in Entity Mapper
- Each Entity must have its own Mapper
- Each Entity must have one internal empty constructor only if it has any non-empty constructor.
- Each Persisted Property has to be marked as Virtual.
- Private setter on property will not work ( it has to be protected/public internal set)
- Any setter method has to be marked as virtual.
- Batch insert is supported. However, Id has to be of type of GUID.
- Inheritance Not Supported For Value Objects, it has to be Entity.
No persister for: User
Solution:- Check if there is no Mapper class defined for that Entity or Component
- Make sure Mapper Class must be public