dotnet / dotnet/efcore

Concurrency on JSON types - System.InvalidOperationException when reading JSON

Open
#33,822 5 comments 0 reactions 0 assignees View on GitHub
area-json customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

System.InvalidOperationException
Cannot get the value of a token type 'Null' as a string.

at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)
at lambda_method2006(Closure, QueryContext, Object[], JsonReaderData)
at lambda_method2005(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)

public class Foo
{
public required Foo2 Foo2{ get; init; }
public required string Bar{ get; init; }
}

public class Foo2
{
...
}

builder.OwnsOne(m => m.Foo).ToJson().OwnsOne(foo=> foo.Foo2);

{..., "_TableSharingConcurrencyTokenConvention_RowVersion":null,"Foo2":{..., "_TableSharingConcurrencyTokenConvention_RowVersion":null}}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.