public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType) { if (oldBaseType != null && oldBaseType.BaseType == null && !oldBaseType.GetDerivedTypes().Any()) { var oldBaseTypeBuilder = oldBaseType.Builder; oldBaseTypeBuilder?.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); } var entityType = entityTypeBuilder.Metadata; var derivedEntityTypes = entityType.GetDerivedTypes().ToList(); DiscriminatorBuilder discriminator; if (entityType.BaseType == null) { if (!derivedEntityTypes.Any()) { entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); return(true); } discriminator = entityTypeBuilder.Relational(ConfigurationSource.Convention) .HasDiscriminator(typeof(string)); } else { if (entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null) == null) { // TODO: log warning that the current discriminator couldn't be removed return(true); } var rootTypeBuilder = entityType.RootType().Builder; discriminator = rootTypeBuilder?.Relational(ConfigurationSource.Convention).HasDiscriminator(typeof(string)); if (entityType.BaseType.BaseType == null) { discriminator?.HasValue(entityType.BaseType.Name, entityType.BaseType.DisplayName()); } } if (discriminator != null) { discriminator.HasValue(entityTypeBuilder.Metadata.Name, entityTypeBuilder.Metadata.DisplayName()); SetDefaultDiscriminatorValues(derivedEntityTypes, discriminator); } return(true); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType) { if (oldBaseType != null && oldBaseType.BaseType == null && !oldBaseType.GetDerivedTypes().Any()) { var oldBaseTypeBuilder = oldBaseType.Builder; oldBaseTypeBuilder?.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); } var entityType = entityTypeBuilder.Metadata; var derivedEntityTypes = entityType.GetDerivedTypes().ToList(); DiscriminatorBuilder discriminator; if (entityType.BaseType == null) { if (!derivedEntityTypes.Any()) { entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); return true; } discriminator = entityTypeBuilder.Relational(ConfigurationSource.Convention) .HasDiscriminator(typeof(string)); } else { if (entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null) == null) { // TODO: log warning that the current discriminator couldn't be removed return true; } var rootTypeBuilder = entityType.RootType().Builder; discriminator = rootTypeBuilder?.Relational(ConfigurationSource.Convention).HasDiscriminator(typeof(string)); if (entityType.BaseType.BaseType == null) { discriminator?.HasValue(entityType.BaseType.Name, entityType.BaseType.DisplayName()); } } if (discriminator != null) { discriminator.HasValue(entityTypeBuilder.Metadata.Name, entityTypeBuilder.Metadata.DisplayName()); SetDefaultDiscriminatorValues(derivedEntityTypes, discriminator); } return true; }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public override InternalEntityTypeBuilder Apply(InternalEntityTypeBuilder entityTypeBuilder, TableAttribute attribute) { if (!string.IsNullOrWhiteSpace(attribute.Schema)) { entityTypeBuilder.Relational(ConfigurationSource.DataAnnotation).ToTable(attribute.Name, attribute.Schema); } if (!string.IsNullOrWhiteSpace(attribute.Name)) { entityTypeBuilder.Relational(ConfigurationSource.DataAnnotation).ToTable(attribute.Name); } return(entityTypeBuilder); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType) { if (oldBaseType != null && oldBaseType.BaseType == null && oldBaseType.GetDirectlyDerivedTypes().Count == 0) { oldBaseType.Builder?.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); } var entityType = entityTypeBuilder.Metadata; var derivedEntityTypes = entityType.GetDerivedTypes().ToList(); DiscriminatorBuilder discriminator; if (entityType.BaseType == null) { if (derivedEntityTypes.Count == 0) { entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null); return(true); } discriminator = entityTypeBuilder.Relational(ConfigurationSource.Convention) .HasDiscriminator(typeof(string)); } else { if (entityTypeBuilder.Relational(ConfigurationSource.Convention).HasDiscriminator(propertyInfo: null) == null) { return(true); } var rootTypeBuilder = entityType.RootType().Builder; discriminator = rootTypeBuilder?.Relational(ConfigurationSource.Convention).HasDiscriminator(typeof(string)); if (entityType.BaseType.BaseType == null) { discriminator?.HasValue(entityType.BaseType.Name, entityType.BaseType.ShortName()); } } if (discriminator != null) { discriminator.HasValue(entityTypeBuilder.Metadata.Name, entityTypeBuilder.Metadata.ShortName()); SetDefaultDiscriminatorValues(derivedEntityTypes, discriminator); } return(true); }
public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType) { if (_sets != null) { var entityType = entityTypeBuilder.Metadata; if (oldBaseType == null && entityType.BaseType != null) { entityTypeBuilder.Relational(ConfigurationSource.Convention).ToTable(null); } else if (oldBaseType != null && entityType.BaseType == null && _sets.ContainsKey(entityType.ClrType)) { entityTypeBuilder.Relational(ConfigurationSource.Convention).ToTable(_sets[entityType.ClrType].Name); } } return(true); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType) { if (_sets != null) { var entityType = entityTypeBuilder.Metadata; if (oldBaseType == null && entityType.BaseType != null) { entityTypeBuilder.Relational(ConfigurationSource.Convention).ToTable(null); } else if (oldBaseType != null && entityType.BaseType == null && _sets.ContainsKey(entityType.ClrType)) { entityTypeBuilder.Relational(ConfigurationSource.Convention).ToTable(_sets[entityType.ClrType].Name); } } return true; }