Skip to content

Manage multiple properties using the same ComplexType in IUpdateAdapter.CreateEntry #37846

Description

@masesdevelopers

Developing a provider for EF Core there is point obscure.
Starting from this simple model:

    [Table("TaxInfo", Schema = "ComplexTest")]
    public class TaxInfo
    {
        public int TaxInfoId { get; set; }
        public char Code { get; set; }
        public decimal Percentage { get; set; }
        [Required]
        public TaxInfoExtended TaxInfoExtended { get; set; }
        [Required]
        public TaxInfoExtended TaxInfoExtended2 { get; set; }
        public int ExtraValue { get; set; } 
    }

    [ComplexType]
    public class TaxInfoExtended
    {
        public int CodeExtended { get; set; }
        public decimal PercentageExtended { get; set; }
    }

currently the data are saved to manage this kind of condition, however the focus of the issue is related on how the complex type can be made available back.
The code is using the following API:

public virtual IUpdateEntry CreateEntry(
IDictionary<string, object?> values,
IEntityType entityType)
=> _stateManager.CreateEntry(values, entityType);

which accept in input a IDictionary<string, object?> then the content is passed to the StateManager and used:

public virtual InternalEntityEntry CreateEntry(IDictionary<string, object?> values, IEntityType entityType)
{
var entry = new InternalEntityEntry(this, entityType, values, EntityMaterializerSource);
UpdateReferenceMaps(entry, EntityState.Detached, null);
return entry;
}

The InternalEntityEntry try to get the properties from the dictionary using the Name property of the flattened list:

foreach (var property in entityType.GetFlattenedProperties())
{
var index = property.GetIndex();
if (index < 0)
{
continue;
}
valuesArray[index] = values.TryGetValue(property.Name, out var value)
? value
: property.Sentinel;
}
Entity = entityType.GetOrCreateMaterializer(entityMaterializerSource)(
new MaterializationContext(new ValueBuffer(valuesArray), stateManager.Context));
}

however, from our test, the flattened list contains all properties, but the Name property of the IProperty does not distinguish between the same property of multiple ComplexType. In the above example how is it possible to fill in the dictionary to distinguish between CodeExtended of TaxInfoExtended and TaxInfoExtended2?
Or, despite from the usage of flattened list of properties in InternalEntityEntry, the dictionary shall be filled in only with the Entity properties and the complex one shall be set using the UpdateEntry class?

Activity

  1. changed the title [-]Manage multiple properties using the same CompleType in IUpdateAdapter.CreateEntry[/-] [+]Manage multiple properties using the same ComplexType in IUpdateAdapter.CreateEntry[/+] on Mar 4, 2026
  2. added this to the 11.0.0 milestone on Mar 5, 2026
  3. added 3 commits that reference this issue on Jun 5, 2026
    8fbf85c
    3441a89
    16bde33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions