public void Delegate_accessor_always_creates_collections_that_use_reference_equality_comparer()
        {
            IMutableModel model      = new Model();
            var           entityType = model.AddEntityType(typeof(MyEntity));
            var           otherType  = model.AddEntityType(typeof(MyEntityWithCustomComparer));
            var           foreignKey = otherType.AddForeignKey(
                otherType.AddProperty("MyEntityId", typeof(int)),
                entityType.SetPrimaryKey(entityType.AddProperty("Id", typeof(int))),
                entityType);

            var navigation = foreignKey.SetPrincipalToDependent(
                typeof(MyEntity).GetProperty(
                    nameof(MyEntity.AsICollectionWithCustomComparer),
                    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance));

            RunConvention(navigation);

            var accessor = new ClrCollectionAccessorFactory().Create((INavigation)navigation);

            var entity = new MyEntity(initialize: false);
            var value  = new MyEntityWithCustomComparer {
                Id = 1
            };

            Assert.False(accessor.Contains(entity, value));

            accessor.Add(entity, value, forMaterialization: false);

            value.Id = 42;

            accessor.Add(entity, value, forMaterialization: false);

            Assert.Equal(1, entity.AsICollectionWithCustomComparer.Count);
        }
        public void Delegate_accessor_always_creates_collections_that_use_reference_equality_comparer()
        {
            var model      = new Model();
            var entityType = model.AddEntityType(typeof(MyEntity));
            var otherType  = model.AddEntityType(typeof(MyEntityWithCustomComparer));
            var foreignKey = otherType.GetOrAddForeignKey(
                otherType.AddProperty("MyEntityId", typeof(int)),
                entityType.GetOrSetPrimaryKey(entityType.AddProperty("Id", typeof(int))),
                entityType);

            var navigation = foreignKey.HasPrincipalToDependent(
                typeof(MyEntity).GetProperty(
                    nameof(MyEntity.AsICollectionWithCustomComparer),
                    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance));

            new BackingFieldConvention(new TestLogger <DbLoggerCategory.Model>()).Apply(foreignKey.Builder, navigation);

            var accessor = new ClrCollectionAccessorFactory().Create(navigation);

            var entity = new MyEntity(initialize: false);
            var value  = new MyEntityWithCustomComparer
            {
                Id = 1
            };

            Assert.False(accessor.Contains(entity, value));

            accessor.Add(entity, value);

            value.Id = 42;

            accessor.Add(entity, value);

            Assert.Equal(1, entity.AsICollectionWithCustomComparer.Count);
        }