Skip to content

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

Open
@lsrigel

Description

@lsrigel

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions