src/Shared/EntityFramework/Core/Mapping/Update/Internal/updatecommandorderer.cs
// <summary>
// For function commands, we infer constraints based on relationships and entities. For instance,
// we always insert an entity before inserting a relationship referencing that entity. When dynamic
// and function UpdateCommands are mixed, we also fall back on this same interpretation.
// </summary>
For function commands, we infer constraints based on relationships and entities. For instance,
we always insert an entity before inserting a relationship referencing that entity. When dynamic
and function UpdateCommands are mixed, we also fall back on this same interpretation.
For function commands we infer constraints based on relationships and entities . For instance we always insert an entity before inserting a relationship referencing that entity . When dynamic and function UpdateCommands are mixed we also fall back on this same interpretation .
private void AddModelDependencies()
        {
            var addedEntities = new KeyToListMap<EntityKey, UpdateCommand>(EqualityComparer<EntityKey>.Default);
            var deletedEntities = new KeyToListMap<EntityKey, UpdateCommand>(EqualityComparer<EntityKey>.Default);
            var addedRelationships = new KeyToListMap<EntityKey, UpdateCommand>(EqualityComparer<EntityKey>.Default);
            var deletedRelationships = new KeyToListMap<EntityKey, UpdateCommand>(EqualityComparer<EntityKey>.Default);
            foreach (var command in Vertices)
            {
                command.GetRequiredAndProducedEntities(
                    _translator, addedEntities, deletedEntities, addedRelationships, deletedRelationships);
            }
            AddModelDependencies(producedMap: addedEntities, requiredMap: addedRelationships);
            AddModelDependencies(producedMap: deletedRelationships, requiredMap: deletedEntities);
        }
private void AddModelDependencies ( ) { var addedEntities = new KeyToListMap < EntityKey , UpdateCommand > ( EqualityComparer < EntityKey > . Default ) ; var deletedEntities = new KeyToListMap < EntityKey , UpdateCommand > ( EqualityComparer < EntityKey > . Default ) ; var addedRelationships = new KeyToListMap < EntityKey , UpdateCommand > ( EqualityComparer < EntityKey > . Default ) ; var deletedRelationships = new KeyToListMap < EntityKey , UpdateCommand > ( EqualityComparer < EntityKey > . Default ) ; foreach ( var command in Vertices ) { command . GetRequiredAndProducedEntities ( _translator , addedEntities , deletedEntities , addedRelationships , deletedRelationships ) ; } AddModelDependencies ( producedMap : addedEntities , requiredMap : addedRelationships ) ; AddModelDependencies ( producedMap : deletedRelationships , requiredMap : deletedEntities ) ; }
For function commands, we infer constraints based on relationships and entities.
For function commands we infer constraints based on relationships and entities .
// Add entities before adding dependent relationships // Delete dependent relationships before deleting entities