protected virtual bool SetDiscriminatorValue(object value)
        {
            if (DiscriminatorProperty == null)
            {
                throw new InvalidOperationException(
                          Strings.NoDiscriminatorForValue(EntityType.DisplayName(), EntityType.RootType().DisplayName()));
            }

            if (value != null && !DiscriminatorProperty.ClrType.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
            {
                throw new InvalidOperationException(Strings.DiscriminitatorValueIncompatible(
                                                        value, DiscriminatorProperty.Name, DiscriminatorProperty.ClrType));
            }

            return(Annotations.SetAnnotation(RelationalAnnotationNames.DiscriminatorValue, value));
        }
        protected virtual bool SetDiscriminatorProperty([CanBeNull] IProperty value)
        {
            if (value != null)
            {
                if (EntityType != EntityType.RootType())
                {
                    throw new InvalidOperationException(
                              RelationalStrings.DiscriminatorPropertyMustBeOnRoot(EntityType));
                }

                if (value.DeclaringEntityType != EntityType)
                {
                    throw new InvalidOperationException(
                              RelationalStrings.DiscriminatorPropertyNotFound(value.Name, EntityType));
                }
            }

            return(Annotations.SetAnnotation(RelationalAnnotationNames.DiscriminatorProperty, value?.Name));
        }