Skip to content
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

OwnsOne ToJson HasConversion #3129

Closed
rsr-maersk opened this issue Mar 8, 2024 · 1 comment
Closed

OwnsOne ToJson HasConversion #3129

rsr-maersk opened this issue Mar 8, 2024 · 1 comment

Comments

@rsr-maersk
Copy link

Hi. Awesome package. Thank you.

According to https://www.npgsql.org/efcore/mapping/json.html?q=tojson&tabs=data-annotations%2Cpoco
we should now use OwnsOne/OwnsMany + ToJson for the json mapping.. Like e.g.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Customer>()
        .OwnsOne(c => c.Details, d =>
        {
            d.ToJson();
            d.OwnsMany(d => d.Orders);
        });
}

But how do we add the valueconverter for serialization on the property? i.e. for a custom serializartion (e.g. nodatime) we need to add serializers.
this was done on HasConversion before.

We cannot "OwnsOne" and Property on modelling, as this gives:

Unable to create a 'DbContext' of type 'E2EJourneyPlanningDbContext'. The exception 'The property or navigation 'PartiesPayload' cannot be added to the 'ServicePlanEntity' type because a property or navigation with the same name already exists on the 'ServicePlanEntity' type.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

So where do we add the client side serializers plz :-)

@rsr-maersk
Copy link
Author

rsr-maersk commented Mar 8, 2024

I see #1107

So my question is simple. How to allow for nodatime to the .ToJson

@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants