src/Shared/EntityFramework/ModelConfiguration/Configuration/Properties/Navigation/ConventionNavigationPropertyConfiguration.cs
// <summary>
// Sets the inverse navigation property.
// </summary>
Sets the inverse navigation property.
Sets the inverse navigation property .
public virtual ConventionNavigationPropertyConfiguration HasInverseNavigationProperty(
            Func<PropertyInfo, PropertyInfo> inverseNavigationPropertyGetter)
        {
            Check.NotNull(inverseNavigationPropertyGetter, "inverseNavigationPropertyGetter");
            if (_configuration != null
                && _configuration.InverseNavigationProperty == null)
            {
                var inverseNavigationProperty = inverseNavigationPropertyGetter(ClrPropertyInfo);
                Check.NotNull(inverseNavigationProperty, "inverseNavigationProperty");
                if (!inverseNavigationProperty.IsValidEdmNavigationProperty())
                {
                    throw new InvalidOperationException(
                        Strings.LightweightEntityConfiguration_InvalidNavigationProperty(inverseNavigationProperty.Name));
                }
                if (!inverseNavigationProperty.DeclaringType.IsAssignableFrom(_configuration.NavigationProperty.PropertyType.GetTargetType()))
                {
                    throw new InvalidOperationException(
                        Strings.LightweightEntityConfiguration_MismatchedInverseNavigationProperty(
                            _configuration.NavigationProperty.PropertyType.GetTargetType().FullName, _configuration.NavigationProperty.Name,
                            inverseNavigationProperty.DeclaringType.FullName, inverseNavigationProperty.Name));
                }
                if (!_configuration.NavigationProperty.DeclaringType.IsAssignableFrom(inverseNavigationProperty.PropertyType.GetTargetType()))
                {
                    throw new InvalidOperationException(
                        Strings.LightweightEntityConfiguration_InvalidInverseNavigationProperty(
                            _configuration.NavigationProperty.DeclaringType.FullName, _configuration.NavigationProperty.Name,
                            inverseNavigationProperty.PropertyType.GetTargetType().FullName, inverseNavigationProperty.Name));
                }
                if (_configuration.InverseEndKind.HasValue)
                {
                    VerifyMultiplicityCompatibility(_configuration.InverseEndKind.Value, inverseNavigationProperty);
                }
                _modelConfiguration
                    .Entity(_configuration.NavigationProperty.PropertyType.GetTargetType())
                    .Navigation(inverseNavigationProperty);
                _configuration.InverseNavigationProperty = inverseNavigationProperty;
            }
            return this;
        }
public virtual ConventionNavigationPropertyConfiguration HasInverseNavigationProperty ( Func < PropertyInfo , PropertyInfo > inverseNavigationPropertyGetter ) { Check . NotNull ( inverseNavigationPropertyGetter , " " ) ; if ( _configuration != null && _configuration . InverseNavigationProperty == null ) { var inverseNavigationProperty = inverseNavigationPropertyGetter ( ClrPropertyInfo ) ; Check . NotNull ( inverseNavigationProperty , " " ) ; if ( ! inverseNavigationProperty . IsValidEdmNavigationProperty ( ) ) { throw new InvalidOperationException ( Strings . LightweightEntityConfiguration_InvalidNavigationProperty ( inverseNavigationProperty . Name ) ) ; } if ( ! inverseNavigationProperty . DeclaringType . IsAssignableFrom ( _configuration . NavigationProperty . PropertyType . GetTargetType ( ) ) ) { throw new InvalidOperationException ( Strings . LightweightEntityConfiguration_MismatchedInverseNavigationProperty ( _configuration . NavigationProperty . PropertyType . GetTargetType ( ) . FullName , _configuration . NavigationProperty . Name , inverseNavigationProperty . DeclaringType . FullName , inverseNavigationProperty . Name ) ) ; } if ( ! _configuration . NavigationProperty . DeclaringType . IsAssignableFrom ( inverseNavigationProperty . PropertyType . GetTargetType ( ) ) ) { throw new InvalidOperationException ( Strings . LightweightEntityConfiguration_InvalidInverseNavigationProperty ( _configuration . NavigationProperty . DeclaringType . FullName , _configuration . NavigationProperty . Name , inverseNavigationProperty . PropertyType . GetTargetType ( ) . FullName , inverseNavigationProperty . Name ) ) ; } if ( _configuration . InverseEndKind . HasValue ) { VerifyMultiplicityCompatibility ( _configuration . InverseEndKind . Value , inverseNavigationProperty ) ; } _modelConfiguration . Entity ( _configuration . NavigationProperty . PropertyType . GetTargetType ( ) ) . Navigation ( inverseNavigationProperty ) ; _configuration . InverseNavigationProperty = inverseNavigationProperty ; } return this ; }
Sets the inverse navigation property.
Sets the inverse navigation property .
inverseNavigationPropertyGetter
Func<PropertyInfo, PropertyInfo>