private EntityType AddEntityType(EntityType entityType) { var entityTypeName = entityType.Name; if (entityType.HasDefiningNavigation()) { if (_entityTypes.ContainsKey(entityTypeName)) { throw new InvalidOperationException(CoreStrings.ClashingNonWeakEntityType(entityType.DisplayName())); } if (!_entityTypesWithDefiningNavigation.TryGetValue(entityTypeName, out var entityTypesWithSameType)) { entityTypesWithSameType = new SortedSet <EntityType>(EntityTypePathComparer.Instance); _entityTypesWithDefiningNavigation[entityTypeName] = entityTypesWithSameType; } var added = entityTypesWithSameType.Add(entityType); Debug.Assert(added); } else { if (_entityTypesWithDefiningNavigation.ContainsKey(entityTypeName)) { throw new InvalidOperationException(CoreStrings.ClashingWeakEntityType(entityType.DisplayName())); } if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue12119", out var isEnabled) && isEnabled) { var previousLength = _entityTypes.Count; _entityTypes[entityTypeName] = entityType; if (previousLength == _entityTypes.Count) { throw new InvalidOperationException(CoreStrings.DuplicateEntityType(entityType.DisplayName())); } } else { if (_entityTypes.TryGetValue(entityTypeName, out var clashingEntityType)) { if (clashingEntityType.IsQueryType) { if (entityType.IsQueryType) { throw new InvalidOperationException(CoreStrings.DuplicateQueryType(entityType.DisplayName())); } throw new InvalidOperationException(CoreStrings.CannotAccessQueryAsEntity(entityType.DisplayName())); } if (entityType.IsQueryType) { throw new InvalidOperationException(CoreStrings.CannotAccessEntityAsQuery(entityType.DisplayName())); } throw new InvalidOperationException(CoreStrings.DuplicateEntityType(entityType.DisplayName())); } _entityTypes.Add(entityTypeName, entityType); } } return(ConventionDispatcher.OnEntityTypeAdded(entityType.Builder)?.Metadata); }
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnKeyAdded(KeyBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnKeyAnnotationChanged( KeyBuilder, Name, Annotation, OldAnnotation);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnSkipNavigationAdded(NavigationBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnSkipNavigationInverseChanged(NavigationBuilder, Inverse, OldInverse);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnForeignKeyNullNavigationSet(RelationshipBuilder, PointsToPrincipal);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnNavigationAnnotationChanged( RelationshipBuilder, Navigation, Name, Annotation, OldAnnotation);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnEntityTypePrimaryKeyChanged( EntityTypeBuilder, NewPrimaryKey, PreviousPrimaryKey);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnIndexAdded(IndexBuilder);
/// <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 ConventionContext(ConventionDispatcher dispatcher) { _dispatcher = dispatcher; }
public abstract void Run(ConventionDispatcher dispatcher);
/// <summary> /// Runs the conventions when an annotation was set or removed. /// </summary> /// <param name="name"> The key of the set annotation. </param> /// <param name="annotation"> The annotation set. </param> /// <param name="oldAnnotation"> The old annotation. </param> /// <returns> The annotation that was set. </returns> protected override Annotation OnAnnotationSet(string name, Annotation annotation, Annotation oldAnnotation) => ConventionDispatcher.OnModelAnnotationChanged(Builder, name, annotation, oldAnnotation);
public InternalModelBuilder([NotNull] Model metadata, [NotNull] ConventionSet conventions) : base(metadata) { ConventionDispatcher = new ConventionDispatcher(conventions); }
public Model([NotNull] ConventionSet conventions) { ConventionDispatcher = new ConventionDispatcher(conventions); Builder = new InternalModelBuilder(this); ConventionDispatcher.OnModelInitialized(Builder); }
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnForeignKeyPropertiesChanged( RelationshipBuilder, OldDependentProperties, OldPrincipalKey);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnIndexUniquenessChanged(IndexBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnForeignKeyDependentRequirednessChanged(RelationshipBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnPropertyNullabilityChanged(PropertyBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnForeignKeyPrincipalEndChanged(RelationshipBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnPropertyFieldChanged(PropertyBuilder, NewFieldInfo, OldFieldInfo);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnNavigationRemoved( SourceEntityTypeBuilder, TargetEntityTypeBuilder, NavigationName, MemberInfo);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnEntityTypeAdded(EntityTypeBuilder);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnSkipNavigationForeignKeyChanged(NavigationBuilder, ForeignKey, OldForeignKey);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnEntityTypeRemoved(ModelBuilder, EntityType);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnSkipNavigationRemoved(EntityTypeBuilder, Navigation);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnEntityTypeMemberIgnored(EntityTypeBuilder, Name);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnKeyRemoved(EntityTypeBuilder, Key);
public override void Run(ConventionDispatcher dispatcher) => dispatcher._immediateConventionScope.OnEntityTypeBaseTypeChanged( EntityTypeBuilder, NewBaseType, PreviousBaseType);
/// <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 InternalModelBuilder Validate() => ConventionDispatcher.OnModelBuilt(Builder);
public override void Run(ConventionDispatcher dispatcher) => Check.DebugAssert(false, "Immediate convention scope cannot be run again.");