Skip to content

Loading entity from DB does not properly load owned entity if one of it's properties is null #24168

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
MalgorzataG26 opened this issue Feb 16, 2021 · 2 comments

Comments

@MalgorzataG26
Copy link

Description

When loading an entity from the DB, some owned entities are not loaded correctly if nullable property is null. We have class First, which has property of type Second. If id in Second is not null, the Third property is loaded, but if id is null, Third is also returned as null.
When we run generated query in database, everything is returned correctly.

    public class First
    {
        public Second Second { get; set; }
    }
    public class Second
    {
        public int? Id { get; set; }
        public Third Third { get; set; }
    }
    public class Third
    {
        public string Xyz { get; set; }
    }

Configuration:

builder.OwnsOne(e => e.Second, second => { second.OwnsOne(s => s.Third); });

EF Core version: 5.0.1
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: .NET core 3.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.8.4

@ajcvickers
Copy link
Contributor

@smitpatel to de-dupe.

@smitpatel
Copy link
Contributor

Duplicate for #23564

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants