EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

Error when calling DeleteAsync() on a query that uses Sql Server HierarchyId type as a column type

Open lsrigel opened this issue 2 years ago • 4 comments

Thanks for the great library, we have just done an upgrade to .Net6 and are seeing the following error.

1. Description

When calling DeleteAsync() on a query that uses Sql Server HierarchyId type as a column type, we get an error (see below)

e.g. (divisionId is type Microsoft.EntityFrameworkCore.HierarchyId)

  await _dbContext.TableName
                       .Where(table => table.DivisionId == divisionId)
                       .DeleteAsync();

2. Exception Stacktrace (trimmed to only include library component)

MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen, Boolean streamAllowed) MetaType.GetMetaTypeFromType(Type dataType) SqlParameter.GetMetaTypeOnly() SqlParameter.Validate(Int32 index, Boolean isCommandProc) SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters, Boolean includeReturnValue) SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc) SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) SqlCommand.ExecuteScalar() <>c.(DbCommand ) BatchDelete.Execute[T](IQueryable1 query) BatchDeleteExtensions.Delete[T](IQueryable1 query, Action1 batchDeleteBuilder) <>c__DisplayClass2_01.<DeleteAsync>b__0() Task1.InnerInvoke() <.cctor>b__272_0(Object obj) ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

Exception message:
"No mapping exists from object type Microsoft.EntityFrameworkCore.HierarchyId to a known managed provider native type." 

4. Any further technical details

This was working fine until a recent upgrade to .Net 6 (from 3.1) Using EF core 6.0.16 image

lsrigel avatar May 30 '23 03:05 lsrigel

Hello @lsrigel ,

Thank you for contacting us.

My developer will look at it if we can easily support this or not.

Best Regards,

Jon

JonathanMagnan avatar May 30 '23 13:05 JonathanMagnan

Hello @lsrigel ,

Just to give you an update: My developer has fixed this issue. The fix will be part of the next release, that will happen in 1 or 2 weeks.

Best Regards,

Jon

JonathanMagnan avatar Jun 01 '23 16:06 JonathanMagnan

Thank you, appreciate the effort

lsrigel avatar Jun 02 '23 02:06 lsrigel

Hello @lsrigel ,

Sorry for the delay, the fix has been finally been released today. If you are using EF Core 6, the fix should be available in the version v6.22.4

Best Regards,

Jon

JonathanMagnan avatar Jul 12 '23 00:07 JonathanMagnan