I've been struggling with this for a while and was surprised how little information is out there. This question is the best I could find and even here the accepted answer doesn't say how to enable entity caching. Here's what I've found out.
To enable second level cache:
Fluently.Configure()
.Database(/* your DB config */)
.Cache(c => c.UseSecondLevelCache().ProviderClass<CacheProviderClass>())
You can use both this and query cache:
Fluently.Configure()
.Database(/* your DB config */)
.Cache(c => c.UseSecondLevelCache()
.UseQueryCache()
.ProviderClass<CacheProviderClass>())
To enable per-entity caching:
.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Entity>()
.Conventions.Add(ConventionBuilder.Class.Always(c => c.Cache.ReadWrite()))
)
)
Of course, you can use ReadOnly() or NonStrictReadWrite() if you wish.