public virtual InternalRelationshipBuilder Apply(InternalRelationshipBuilder relationshipBuilder) { Check.NotNull(relationshipBuilder, nameof(relationshipBuilder)); var fk = relationshipBuilder.Metadata; var fromDeclaring = FindRelationshipAttributeOnProperty( fk.DeclaringEntityType, fk.DependentToPrincipal?.Name ); var fromPrincipal = FindRelationshipAttributeOnProperty( fk.PrincipalEntityType, fk.PrincipalToDependent?.Name ); if (!(fromDeclaring is null) && !(fromPrincipal is null)) { throw new InvalidOperationException( CypherStrings.DuplicateRelationshipAttribute( fk.DeclaringEntityType.DisplayName(), fk.DependentToPrincipal?.Name, fk.PrincipalEntityType.DisplayName(), fk.PrincipalToDependent?.Name ) ); } if (!(fromDeclaring is null)) { relationshipBuilder .Cypher(ConfigurationSource.DataAnnotation) .HasRelationship( fromDeclaring.Name ?? fromDeclaring.Type.DisplayName(), fk.DeclaringEntityType.Name ?? fk.DeclaringEntityType.ClrType.DisplayName() ); } if (!(fromPrincipal is null)) { relationshipBuilder .Cypher(ConfigurationSource.DataAnnotation) .HasRelationship( fromPrincipal.Name ?? fromPrincipal.Type.DisplayName(), fk.PrincipalEntityType.Name ?? fk.PrincipalEntityType.ClrType.DisplayName() ); } return(relationshipBuilder); }