开发者

Entity Framework: Disabling EFCachingProvider For Stored Procedures

开发者 https://www.devze.com 2023-03-29 13:44 出处:网络
EFCachingProvider produces the following error when calling stored procedures: System.NotSupportedException: Command tree type

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

0

精彩评论

暂无评论...
验证码 换一张
取 消