efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null

Open rvplauborg opened this issue 2 years ago • 3 comments

File a bug

Please see #29219 for context. This issue is precisely described in the comment https://github.com/dotnet/efcore/issues/29219#issuecomment-1356886149 that was added and is related to #29219.

When a new nullable property is added to a model mapped as json, then querying on that should not error, but instead missing json values in the data should just map to null. According to #29219 looks like this was fixed for simple types (string, int, ..) but still does not work for complex types.

Include provider and version information

EF Core version: 7.0.0 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 7.0

rvplauborg avatar Jan 11 '23 10:01 rvplauborg

/cc @maumar

ajcvickers avatar Jan 11 '23 21:01 ajcvickers

When accessing sub-element within JsonElement in materialization code we use JsonElement.GetProperty. We should use the TryGetProperty instead

maumar avatar Jan 18 '23 05:01 maumar

Note from triage: bring to Tactics for patching.

ajcvickers avatar Jan 19 '23 15:01 ajcvickers

reopening for potential servicing

maumar avatar Feb 24 '23 04:02 maumar

when will v7.0.5 be released?

meichhorn-conet avatar Mar 22 '23 05:03 meichhorn-conet