src/Shared/EntityFramework/Core/Metadata/Edm/StructuralType.cs
// <summary>
// Adds a member to this type.
// </summary>
// <param name="member">The member to add.</param>
// <param name="forceAdd">
// Indicates whether the addition is forced, regardless of
// whether read-only is set.
// </param>
// <remarks>
// Adding a NavigationProperty to an EntityType introduces a circular dependency between
// EntityType and AssociationEndMember, which is worked around by calling this method.
// This is the case of OneToOneMappingBuilder, in the designer. Must not be used in other context.
// </remarks>
Adds a member to this type.
Adds a member to this type .
internal void AddMember(EdmMember member, bool forceAdd)
        {
            Check.NotNull(member, "member");
            if (!forceAdd)
            {
                Util.ThrowIfReadOnly(this);
            }
            if (DataSpace != member.TypeUsage.EdmType.DataSpace
                && BuiltInTypeKind != BuiltInTypeKind.RowType)
            {
                throw new ArgumentException(
                    Strings.AttemptToAddEdmMemberFromWrongDataSpace(
                        member.Name,
                        this.Name,
                        member.TypeUsage.EdmType.DataSpace,
                        this.DataSpace),
                    "member");
            }
            if (BuiltInTypeKind.RowType == BuiltInTypeKind)
            {
                if (_members.Count == 0)
                {
                    DataSpace = member.TypeUsage.EdmType.DataSpace;
                }
                else if (DataSpace != (DataSpace)(-1)
                         && member.TypeUsage.EdmType.DataSpace != DataSpace)
                {
                    DataSpace = (DataSpace)(-1);
                }
            }
            if (_members.IsReadOnly && forceAdd)
            {
                _members.ResetReadOnly();
                _members.Add(member);
                _members.SetReadOnly();
            }
            else
            {
                _members.Add(member);
            }
        }
internal void AddMember ( EdmMember member , bool forceAdd ) { Check . NotNull ( member , " " ) ; if ( ! forceAdd ) { Util . ThrowIfReadOnly ( this ) ; } if ( DataSpace != member . TypeUsage . EdmType . DataSpace && BuiltInTypeKind != BuiltInTypeKind . RowType ) { throw new ArgumentException ( Strings . AttemptToAddEdmMemberFromWrongDataSpace ( member . Name , this . Name , member . TypeUsage . EdmType . DataSpace , this . DataSpace ) , " " ) ; } if ( BuiltInTypeKind . RowType == BuiltInTypeKind ) { if ( _members . Count == 0 ) { DataSpace = member . TypeUsage . EdmType . DataSpace ; } else if ( DataSpace != ( DataSpace ) ( - 1 ) && member . TypeUsage . EdmType . DataSpace != DataSpace ) { DataSpace = ( DataSpace ) ( - 1 ) ; } } if ( _members . IsReadOnly && forceAdd ) { _members . ResetReadOnly ( ) ; _members . Add ( member ) ; _members . SetReadOnly ( ) ; } else { _members . Add ( member ) ; } }
Adds a member to this type.
Adds a member to this type .
// Since we set the DataSpace of the RowType to be -1 in the constructor, we need to initialize it // as and when we add members to it // Do this only when you are adding the first member // We need to build types that span across more than one space. For such row types, we set the  // DataSpace to -1
member
EdmMember
The member to add.
The member to add .
forceAdd
bool
Indicates whether the addition is forced, regardless of
whether read-only is set.
Indicates whether the addition is forced regardless of whether read - only is set .
remarks
Adding a NavigationProperty to an EntityType introduces a circular dependency between
EntityType and AssociationEndMember, which is worked around by calling this method.
This is the case of OneToOneMappingBuilder, in the designer. Must not be used in other context.
Adding a NavigationProperty to an EntityType introduces a circular dependency between EntityType and AssociationEndMember which is worked around by calling this method . This is the case of OneToOneMappingBuilder in the designer . Must not be used in other context .