Skip to content

Default value for a navigation to an owned entity #38682

Description

@ZzZombo

Question

Is having a default non-null value for a navigation property to an owned entity type supported in EF Core? I've seen the docs and issues like #18007 that this shouldn't be done for non-collection navigations to regular entity types, but this presumably do not cover owned entities because they are an integral part of of owning entity and I do not see any harm in doing this. Is my assessment correct?

Your code

[Owned]
class Owned;
class Owner
{
	public Owned NavProp { get; set; } // = new();
}

EF Core version

9.0.0

Database provider

No response

Target framework

.NET 9.0

Operating system

Windows 10

IDE

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions