Example #1
0
        private void CreateModelNavigationProperty(AssociationEndMember from, AssociationEndMember to)
        {
            var entityType        = (EntityType)((RefType)from.TypeUsage.EdmType).ElementType;
            var uniqueMemberNames = new UniqueIdentifierService(StringComparer.OrdinalIgnoreCase);

            LoadNameLookupWithUsedMemberNames(entityType, uniqueMemberNames);

            var name = CreateModelName(GetNavigationPropertyName(_pluralizationService, to, to.Name), uniqueMemberNames);
            var navigationProperty = NavigationProperty.Create(
                name,
                to.TypeUsage,
                (AssociationType)to.DeclaringType,
                from,
                to,
                null);

            entityType.AddNavigationProperty(navigationProperty);
        }