dotnet / dotnet/efcore

Support shadow properties on value type complex types

Open
#35,337 0 comments 0 reactions 0 assignees View on GitHub
area-complex-types
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Currently we don't support shadow properties on value type complex types as they could be a pit of failure. Consider the following case where `Address` has a shadow `Verified` property:

```C#
var customerEntry1 = context.Entry(customer1);
customerEntry1.ComplexProperty(v => v.Address).Property("Verified").CurrentValue = true;

customer2.Address = customer1.Address;
```

What is the value of the `Verified` property on `customer2.Address`? If `Address` was a reference type it would be `true`, but since it's not EF change tracking doesn't have any way to determine that the shadow property values should be copied, so it will be `false`.

This behavior is unintuitive and could lead to subtle issues.

This said, we still want to hear whether anyone has a scenario that requires them to use shadow properties on collections or non-collections of value complex types.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.