private static void CreateStorageAssociationReferentialConstraintProperties(LinqToEdmx.Model.Storage.Association association, IEnumerable<AssociationProperty> properties, bool isParentEntity)
        {
            //  <ReferentialConstraint>
            //      <Principal Role="Category">
            //          <PropertyRef Name="CategoryId" />
            //      </Principal>
            //      <Dependent Role="Product">
            //          <PropertyRef Name="CategoryId" />
            //      </Dependent>
            //  </ReferentialConstraint>
            foreach (var property in properties) {
                var principalProp = !isParentEntity ? property.Property : property.ForeignProperty;
                var dependentProp = !isParentEntity ? property.ForeignProperty : property.Property;

                var principalProperty = association.ReferentialConstraint.Principal.PropertyRefs.Where(p => p.Name == principalProp.KeyName).FirstOrDefault();
                if (principalProperty == null) {
                    principalProperty = new PropertyRef() {
                        Name = principalProp.KeyName
                    };
                    association.ReferentialConstraint.Principal.PropertyRefs.Add(principalProperty);
                }

                var dependentProperty = association.ReferentialConstraint.Dependent.PropertyRefs.Where(p => p.Name == dependentProp.KeyName).FirstOrDefault();
                if (dependentProperty == null) {
                    dependentProperty = new PropertyRef() {
                        Name = dependentProp.KeyName
                    };
                    association.ReferentialConstraint.Dependent.PropertyRefs.Add(dependentProperty);
                }
            }
        }
        private AssociationEnd CreateStorageAssociationEnd(IEntity entity, string role, LinqToEdmx.Model.Storage.Association assocication, bool isCascadeDelete)
        {
            //  <End Role="Category" Type="PetShopModel1.Store.Category" Multiplicity="1">
            //     <OnDelete Action="Cascade" />
            //  </End>
            //  <End Role="Product" Type="PetShopModel1.Store.Product" Multiplicity="*" />
            var end = new AssociationEnd() {
                Role = role,
                Type = String.Concat(StorageSchema.Namespace, ".", entity.EntityKeyName)
            };

            if (isCascadeDelete) {
                end.OnDelete.Add(new OnAction() {
                    Action = EdmxConstants.OnDeleteActionCascade
                });
            }

            assocication.Ends.Add(end);

            return end;
        }