/// <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> protected virtual void AddNavigationProperties([NotNull] IMutableForeignKey foreignKey) { Check.NotNull(foreignKey, nameof(foreignKey)); var dependentEndExistingIdentifiers = ExistingIdentifiers(foreignKey.DeclaringEntityType); var dependentEndNavigationPropertyCandidateName = _candidateNamingService.GetDependentEndCandidateNavigationPropertyName(foreignKey); var dependentEndNavigationPropertyName = _cSharpUtilities.GenerateCSharpIdentifier( dependentEndNavigationPropertyCandidateName, dependentEndExistingIdentifiers, singularizePluralizer: null, uniquifier: NavigationUniquifier); foreignKey.SetDependentToPrincipal(dependentEndNavigationPropertyName); if (foreignKey.DeclaringEntityType.IsKeyless) { return; } var principalEndExistingIdentifiers = ExistingIdentifiers(foreignKey.PrincipalEntityType); var principalEndNavigationPropertyCandidateName = foreignKey.IsSelfReferencing() ? string.Format( CultureInfo.CurrentCulture, SelfReferencingPrincipalEndNavigationNamePattern, dependentEndNavigationPropertyName) : _candidateNamingService.GetPrincipalEndCandidateNavigationPropertyName( foreignKey, dependentEndNavigationPropertyName); if (!foreignKey.IsUnique && !foreignKey.IsSelfReferencing()) { principalEndNavigationPropertyCandidateName = _options.NoPluralize ? principalEndNavigationPropertyCandidateName : _pluralizer.Pluralize(principalEndNavigationPropertyCandidateName); } var principalEndNavigationPropertyName = _cSharpUtilities.GenerateCSharpIdentifier( principalEndNavigationPropertyCandidateName, principalEndExistingIdentifiers, singularizePluralizer: null, uniquifier: NavigationUniquifier); foreignKey.SetPrincipalToDependent(principalEndNavigationPropertyName); }
/// <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> protected virtual void AddNavigationProperties(IMutableForeignKey foreignKey) { if (foreignKey == null) { throw new ArgumentNullException(nameof(foreignKey)); } var dependentEndExistingIdentifiers = ExistingIdentifiers(foreignKey.DeclaringEntityType); var dependentEndNavigationPropertyCandidateName = _candidateNamingService.GetDependentEndCandidateNavigationPropertyName(foreignKey); var dependentEndNavigationPropertyName = _cSharpUtilities.GenerateCSharpIdentifier( dependentEndNavigationPropertyCandidateName, dependentEndExistingIdentifiers, singularizePluralizer: null, uniquifier: NavigationUniquifier); foreignKey.HasDependentToPrincipal(dependentEndNavigationPropertyName); var principalEndExistingIdentifiers = ExistingIdentifiers(foreignKey.PrincipalEntityType); var principalEndNavigationPropertyCandidateName = foreignKey.IsSelfReferencing() ? string.Format( CultureInfo.CurrentCulture, SelfReferencingPrincipalEndNavigationNamePattern, dependentEndNavigationPropertyName) : _candidateNamingService.GetPrincipalEndCandidateNavigationPropertyName( foreignKey, dependentEndNavigationPropertyName); if (!foreignKey.IsUnique && !foreignKey.IsSelfReferencing()) { principalEndNavigationPropertyCandidateName = _pluralizer.Pluralize(principalEndNavigationPropertyCandidateName); } var principalEndNavigationPropertyName = _cSharpUtilities.GenerateCSharpIdentifier( principalEndNavigationPropertyCandidateName, principalEndExistingIdentifiers, singularizePluralizer: null, uniquifier: NavigationUniquifier); foreignKey.HasPrincipalToDependent(principalEndNavigationPropertyName); }