Entity Framework: Disabling EFCachingProvider For Stored Procedures
EFCachingProvider produces the following error when calling stored procedures:
System.NotSupportedException: Command tree type System.Data.Common.CommandTrees.DbFunctionCommandTree is not supported.
But even if you create a separate context and don't set the Cache on it, the error still persists.
We have the following constructor on our Ob开发者_Go百科jectContext:
public ExtendedEntities(string connectionString, params string[] wrapperProviders)
: base(EntityConnectionWrapperUtils.CreateEntityConnectionWithWrappers(connectionString, wrapperProviders))
{
}
Most queries are successfully executed using the following:
ExtendedEntities context = new ExtendedEntities(settings.EntitiesConnectionString, "EFTracingProvider", "EFCachingProvider"))
context.Cache = ...;
context.CachingPolicy = ...;
The stored procedures calls are now using:
new ExtendedEntities(settings.EntitiesConnectionString, "EFTracingProvider");
And yet the issue persists?
I think you should consider using the non-extended version of your Entities class to call the SPs as the wrapper doesn't like the command tree structure of the SPs.
In a case like yours I do the following:
using context as New MyEntities
context.DoSomethingHERE()
end using
精彩评论