-
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
EF returning NULL from queries for entities that include nested owned types #21807
Comments
Note that this is not an issue using EF Core 3.1.6. This seems to be a regression in the 5.0 bits. |
Note for triage: Confirmed this passes with EF Core 3.1, but fails with the latest daily build. We should investigate further given this is a regression. |
@primarilysoftware - Fix for this is included in 5.0. You should be able to get back 3.1 behavior by marking protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Entity>(builder =>
{
builder.HasKey(x => x.Id);
builder.OwnsOne(x => x.Contact, contact =>
{
contact.OwnsOne(c => c.Address);
});
builder.Navigation(x => x.Contact).IsRequired(); // Add this line
});
base.OnModelCreating(modelBuilder);
} |
I have a EF model for an entity like:
When using EF to query for these entities, if
Contact.Name
is null, theContact
property of all queried entities is always null, even ifContact.Address
is non null.Steps to reproduce
Further technical details
EF Core version: 5.0.0-preview.7.20365.15
Database provider: I can reproduce this issue in SQLite and SqlServer
Target framework: .NET Core 3.1
Operating system: Windows
IDE: Visual Studio 2019 16.6.2
The text was updated successfully, but these errors were encountered: