dotnet / dotnet/efcore

Support evolving the document model stored in relational columns

Open
#32,301 30 comments 26 reactions 0 assignees View on GitHub
area-json customer-reported needs-design
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Hi there,
looking for an example on:

**How to update/change with migration the exitsing data in the JsonColumns so I don't run into not exsiting paths exception?**

Just saw dotnefconf 2023... great job, instantly playing a bit around how it behaves with model changes over dev/app lifetime.

Creation worked fine...

```
public class BlogLinks
{
public string? Url { get; set; }
public string? Text { get; set; }
}
```
![image](https://github.com/dotnet/efcore/assets/7533842/85679c51-e00f-4af1-a4bd-f67935b0fd22)

After model change

```
public class BlogLinks
{
public string? Url { get; set; }
public string? Text { get; set; }
public string? SomeThingNew { get; set; }
}
```
the `dotnet ef database update` was successful but did not any change to the data JSON in the JSON Columns,
like adding the new Property of Model eg `{ SomeThingNew : null } `

So although the model in C# knows the property `SomeThingNew `
adding some info throws "**Property cannot be found on the specified JSON path**"

![image](https://github.com/dotnet/efcore/assets/7533842/0f880b7a-a6b0-4660-acc5-dbc27a378279)

Adding new one is no problem:

![image](https://github.com/dotnet/efcore/assets/7533842/be836e5e-7bc6-4739-928e-639d2d677dbf)

So it's just how is the EF8 Core way of doing this migration update on existing models in json data right.

Cheers Otto.

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.