Skip to content

OwnOne entities with default values not saved in TPH scenario #37525

@Tyf0x

Description

@Tyf0x

Bug description

When using Table-Per-Hierarchy (TPH) inheritance with owned entities (OwnsOne), EF Core 8 generates an UPDATE statement but omits the owned entity columns when:

  • An owned entity property starts as null in the database
  • It's then set to an instance where all properties have their CLR default values (e.g., EnumValue.Unknown = 0, IsBool = false)
  • Nullable reference types are disabled (disable in the project file)

This leads to data corruption, preventing us from effectively upgrading from EF core 7 to EF core 8/9/10.

Please find a sample repro project attached.
EfCoreEnumNullTest.zip

EF Core version

8/9/10

Database provider

SqlServer

Target framework

.NET 10

IDE

rider

Metadata

Metadata

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions