Closed fzhangddt closed 3 years ago
Memory cache works in memory and might, be coincidence work even with highly volatile objects like EF proxies. It is a bad idea to cache those in general. A distributed cache like Redis require serialization to binary or string, which doesn't work well with dynamic objects.
EF Proxies are usually used to lazy load dependencies and might not be real objects. Just don't cache them, load your data into POCOs and cache that.
We use CacheManager with MicrosoftMemoryCache. Now we want to use CacheManager backplaned by Azure Redis but we run into the error below. I did some research, by default Entity Framework creates proxy, but we already set ProxyCreationEnabled to false in EF. How can I disable Cachemanager to use the proxy type? Please note the same code works with CacheManager with MicrosoftMemoryCache.
Settings: we use .net 4.7.2 and asp.net, hosted in azure app service. we use CacheManager.Core, Version=1.2.0.0 The DataSet class is marked with "DataContract", "DataMember". The code throwing the exception is:
ICacheManager<DataSet>.Get(cacheKey)
Thanks a lot!