/// <summary>
    ///     Called after the base type of an entity type changes.
    /// </summary>
    /// <param name="entityTypeBuilder">The builder for the entity type.</param>
    /// <param name="newBaseType">The new base entity type.</param>
    /// <param name="oldBaseType">The old base entity type.</param>
    /// <param name="context">Additional information associated with convention execution.</param>
    public virtual void ProcessEntityTypeBaseTypeChanged(
        IConventionEntityTypeBuilder entityTypeBuilder,
        IConventionEntityType?newBaseType,
        IConventionEntityType?oldBaseType,
        IConventionContext <IConventionEntityType> context)
    {
        var entityType = entityTypeBuilder.Metadata;

        if (oldBaseType == null &&
            newBaseType != null)
        {
            entityTypeBuilder.HasNoAnnotation(RelationalAnnotationNames.TableName);
        }
        else if (oldBaseType != null &&
                 newBaseType == null &&
                 !entityType.HasSharedClrType &&
                 _sets.TryGetValue(entityType.ClrType, out var setName))
        {
            entityTypeBuilder.ToTable(setName);
        }
    }
예제 #2
0
        /// <summary>
        ///     Called after the base type of an entity type changes.
        /// </summary>
        /// <param name="entityTypeBuilder"> The builder for the entity type. </param>
        /// <param name="newBaseType"> The new base entity type. </param>
        /// <param name="oldBaseType"> The old base entity type. </param>
        /// <param name="context"> Additional information associated with convention execution. </param>
        public virtual void ProcessEntityTypeBaseTypeChanged(
            IConventionEntityTypeBuilder entityTypeBuilder,
            IConventionEntityType newBaseType,
            IConventionEntityType oldBaseType,
            IConventionContext <IConventionEntityType> context)
        {
            var entityType = entityTypeBuilder.Metadata;

            if (oldBaseType == null &&
                newBaseType != null)
            {
                entityTypeBuilder.HasNoAnnotation(RelationalAnnotationNames.TableName);
            }
            else if (oldBaseType != null &&
                     newBaseType == null &&
                     entityType.ClrType != null &&
                     _sets.ContainsKey(entityType.ClrType))
            {
                entityTypeBuilder.ToTable(_sets[entityType.ClrType].Name);
            }
        }