Example #1
0
        /// <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 override bool Apply(
            InternalModelBuilder modelBuilder,
            Type type,
            PropertyInfo navigationPropertyInfo,
            Type targetClrType,
            InversePropertyAttribute attribute)
        {
            var declaringType = navigationPropertyInfo.DeclaringType;

            Debug.Assert(declaringType != null);
            if (modelBuilder.Metadata.FindEntityType(declaringType) != null)
            {
                return(true);
            }

            var leastDerivedEntityTypes = modelBuilder.FindLeastDerivedEntityTypes(
                declaringType,
                t => !t.IsIgnored(navigationPropertyInfo.Name, ConfigurationSource.DataAnnotation));

            foreach (var leastDerivedEntityType in leastDerivedEntityTypes)
            {
                Apply(leastDerivedEntityType, navigationPropertyInfo, targetClrType, attribute);
            }
            return(true);
        }