When I published the Beta version of EFCache back in May I intentionally did not call it Beta-1 since at that time I did not plan to ship Beta-2. Instead, I wanted to go straight to the RTM. Alas! It turned out that EFCache could not be used with models where CUD (Create/Update/Delete) operations where mapped to stored procedures. Another problem was that in scenarios where there were multiple databases with the same schema EFCache returned cached results even if the database the app was connecting changed. I also got a pull request which I wanted to include. As a result I decided to ship Beta-2. Here is the full list of what’s included in this release:
- support for models containing CUD operations mapped to stored procedures – invoking a CUD operation will invalidate cache items for the given entity set
CacheTransactionHandler.AddAffectedEntitySets
is now protected – makes subclassingCacheTransactionHandler
easier- database name is now part of the cache key – enables using the same cache across multiple databases with the same schema/structure
- new
Cached()
extension method forces caching results for selected queries – results for queries marked withCached()
method will be cached regardless of caching policy, whether the query has been blacklisted or if it contains non-deterministic SQL functions. This feature started with a contribution from ragoster - new name – Second Level Cache for Entity Framework 6.1+ – (notice ‘+’) to indicate that EFCache works not only with Entity Framework 6.1 but also with newer point releases (i.e. all releases up to, but not including, the next major release)
The new version has been uploaded to NuGet, so update the package in your project and let me know of any issues. If I don’t hear back from you I will release the final version in a month or so.
I’m only just seeing this but it’s really exciting. Keep up the good work.
LikeLike
Thank you!
LikeLike
[…] is very exciting! Finally after some travelling and getting the beta-2 version of the Second Level Cache for EF 6.1+ out the door I was able to focus on store functions for EF Code First. I pushed quite hard for the […]
LikeLike
Hi Pawel,
first I want to thank you for the hard work!
I use your EfCache in my running webapplication and since there I get the following error sometimes:
“Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries”
StackTrace:
bei System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
bei System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
bei System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
bei System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
bei System.Data.SqlClient.SqlDataReader.get_MetaData()
bei System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
bei System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
bei System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
bei System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
bei EFCache.CachingCommand.ExecuteDbDataReader(CommandBehavior behavior)
bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
Thanks and and best regards!
LikeLike
Sorry, the error has nothing to do with your EfCache.
The problem came from this linq query:
“query.Where(x => words.All(w => x.Title.Contains(w)))” // words.Length to big!
LikeLike
I am glad you were able to resolve the issue. I was about to comment that it is unlikely the issue was introduced by the cache since the cache does not rewrite/change the SQL queries.
Thanks,
Pawel
LikeLike
Hi again, the EfCache definitly doesn’t work with Spatial columns.
https://efcache.codeplex.com/discussions/546912
Are there any news about it?
Thanks and and best regards!
LikeLike
I forgot to update the discussion on codeplex. There is a design flaw in EF due to which it’s impossible to use spatial types with a wrapping provider if result buffering is turned on. For more details take a look at this bug: https://efcache.codeplex.com/workitem/6
Thanks,
Pawel
LikeLike
Hi Pawel, I tried to implement a custom CachingPolicy to exclude specific tables (contains spatial column).
The problem is, that you declare the virtual method as internal:
protected internal virtual bool CanBeCached
Are threre any reasons you did that?
Thanks
LikeLike
It’s not just internal – it’s protected internal so you still should be able to override it – see http://msdn.microsoft.com/en-us/library/ms173121.aspx for more details.
LikeLike
Thanks for your quick response! I didn’t know the ‘protected internal’ access modifiers.
(The error happens through different Entity-Framework versions in my assemblys)
Thanks
LikeLike