You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Update a null value on JSON column not working #33392
When i update the column with a value i works well
But if there is an value in the column and i want to update with an null value the update is ignored on the json column everything else is updated.
Include your code
protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){base.OnModelCreating(modelBuilder);modelBuilder.Entity<Charger>().OwnsOne(c =>c.Subjekt, s =>s.ToJson()).OwnsOne(c =>c.Zustell_Subjekt, s =>s.ToJson());}publicpartialclassCharger{[Key]publicGuidId{get;set;}publicint?Id_Subjekt{get;set;}publicint?Id_Zustelladresse{get;set;}publicSubjektDto?Subjekt{get;set;}publicSubjektDto?Zustell_Subjekt{get;set;}}publicrecordSubjektDto{publicint?Id{get;set;}publicstring?Name{get;set;}publicstring?Vorname{get;set;}publicstring?Adresse{get;set;}publicstring?PLZ{get;set;}publicstring?Ort{get;set;}publicstring?Telefon{get;set;}publicstring?Email{get;set;}publicint?SubjektTyp{get;set;}publicstring?Strasse{get;set;}publicint?HausNr{get;set;}publicstring?HausNrZusatz{get;set;}}
SELECT [Subjekt] FROM [dbo].[Chargers]
returns NULL
_db.Chargers.Update(charger); // with Value
await _db.SaveChangesAsync();
SELECT [Subjekt] FROM [dbo].[Chargers]
returns JSON
_db.Chargers.Update(charger); // with Null on Subjekt
await _db.SaveChangesAsync();
SELECT [Subjekt] FROM [dbo].[Chargers]
returns JSON
@NikLuy it would be helpful if you could submit a minimal, runnable code sample (i.e. console program) rather than the code snippets - that would help us investigate it much faster.
Activity
roji commentedon Mar 25, 2024
@ajcvickers not sure if you're the best person to investigate this or @maumar...
roji commentedon Mar 25, 2024
@NikLuy it would be helpful if you could submit a minimal, runnable code sample (i.e. console program) rather than the code snippets - that would help us investigate it much faster.
NikLuy commentedon Mar 26, 2024
I work on it. The simple example workes as expected and updates the null values.
So i have build a more complex example to reproduce the problem.
NikLuy commentedon Mar 26, 2024
I Uploaded a simple API which has 4 Endpoints
https://github.com/NikLuy/JsonDemo
ajcvickers commentedon Mar 26, 2024
Duplicate of dotnet/EntityFramework.Docs#4669