-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot serialize Dictionary<string, string> in a JSON column #30707
Comments
Note from triage: validate that mapped property bags contain mapped properties, other than just auto-generated key properties, excluding join tables. This likely needs to be done for both Cosmos and relational, and for both JSON and table mapping. |
I encountered this too. In addition to the problem mentioned above I'm also getting an exception when trying to read the column (described in #32431) |
Is this a duplicate of #29825? |
ajcvickers
added
closed-duplicate
and removed
type-enhancement
area-model-building
labels
Jan 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I seem to be unable to serialize dictionaries in a JSON column with the new JSON support for SQL Server
The database which I created manually via SQL has one table Things with columns ThingId (identity, int), Data (nvarchar(4000)), Child(nvarchar(4000)).
In the database both dictionaries are serialized as {}, the name property of the child serializes properly. The Dictionary inside ChildThing is deserialized as empty dictionary which is to be expected considering the wrong serialization. Bizarrely the Dictionary that is directly inside Thing is deserialized as a dictionary with 1 element where the Key is "ThingId" and the value is whatever the id from the database is. Removing the Data or the Child property from Thing doesn't seem to affect the behavior of the other property.
The console output is
{"ThingId":0,"Child":{"Name":"Foo","Data":{"test":"2"}},"Data":{"test":"1"}}
Thing: 1,
Thing.Data:ThingId:1
Child.Name: Foo, Child.Data.Count: 0
EF Core version: 7
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
The text was updated successfully, but these errors were encountered: