Skip to content

EF9: SaveChanges() is significantly slower in .NET9 vs. .NET8 when using .ToJson() Mapping vs. PostgreSQL Legacy POCO mapping #35239

@c5racing

Description

@c5racing

We use PostgreSQL and are in the process of migrating from .NET8 to .NET9 and in doing so, changing from the Legacy POCO mapping to the newer .ToJson() Mapping.

In the attached sample, there is no data actually being modified. In all cases, dbContext.ChangeTracker.HasChanges(); returns false.

.NET8, version 8.0.11
Legacy Poco Mapping: 0ms
.ToJson(): 300ms

.NET9, version 9.0.0
Legacy Poco Mapping: 0ms
.ToJson(): 2500ms

In both cases, .ToJson() takes longer; however, the difference between .NET8 and .NET9 is 10x more.

The sample references .NET9; however, can be changed to .NET8 for testing. It also relies on Docker for Testcontainers.PostgreSql

https://drive.google.com/file/d/1A_VoN9XgrogMEeevV7mtLh5c2s-Ds2rt/view?usp=drive_link

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions