/// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            // Get a reference to the model element that is being described.
            ModelEnum modelEnum = ModelElement as ModelEnum;

            //Add the descriptor for the tracking property.
            if (modelEnum != null)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            // Get a reference to the model element that is being described.
            Association association = ModelElement as Association;

            //Add the descriptor for the tracking property.
            if (association != null)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo collectionClassPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId);
                DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] collectionClassAttributes =
                {
                    new DisplayNameAttribute("Collection Class"),
                    new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is Association association)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                // only display roles for 1..1 and 0-1..0-1 associations
                if (((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) &&
                     (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne)))
                {
                    PropertyDescriptor sourceRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceRole");
                    propertyDescriptors.Remove(sourceRoleTypeDescriptor);

                    PropertyDescriptor targetRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetRole");
                    propertyDescriptors.Remove(targetRoleTypeDescriptor);
                }

                // only display delete behavior on the principal end
                if (association.SourceRole != EndpointRole.Principal)
                {
                    PropertyDescriptor sourceDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceDeleteAction");
                    propertyDescriptors.Remove(sourceDeleteActionTypeDescriptor);
                }

                if (association.TargetRole != EndpointRole.Principal)
                {
                    PropertyDescriptor targetDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetDeleteAction");
                    propertyDescriptors.Remove(targetDeleteActionTypeDescriptor);
                }

                /********************************************************************************/

                DomainPropertyInfo collectionClassPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId);
                DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] collectionClassAttributes =
                {
                    new DisplayNameAttribute("Collection Class"),
                    new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Beispiel #4
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is ModelEnum modelEnum)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));

                /********************************************************************************/

                DomainPropertyInfo outputDirectoryPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.OutputDirectoryDomainPropertyId);
                DomainPropertyInfo isOutputDirectoryTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsOutputDirectoryTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] outputDirectoryAttributes =
                {
                    new DisplayNameAttribute("Output Directory"),
                    new DescriptionAttribute("Overrides default output directory"),
                    new CategoryAttribute("Code Generation"),
                    new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, outputDirectoryPropertyInfo, isOutputDirectoryTrackingPropertyInfo, outputDirectoryAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Beispiel #5
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            ModelAttribute modelAttribute = ModelElement as ModelAttribute;

            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (modelAttribute != null)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;

                EFCoreValidator.RemoveHiddenProperties(propertyDescriptors, modelAttribute);

                // dono't display IdentityType unless the IsIdentity is true
                if (!modelAttribute.IsIdentity)
                {
                    PropertyDescriptor identityTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "IdentityType");
                    propertyDescriptors.Remove(identityTypeDescriptor);
                }

                /********************************************************************************/

                DomainPropertyInfo columnNamePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId);
                DomainPropertyInfo isColumnNameTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] columnNameAttributes =
                {
                    new DisplayNameAttribute("Column Name"),
                    new DescriptionAttribute("Overrides default column name"),
                    new CategoryAttribute("Database")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute, columnNamePropertyInfo, isColumnNameTrackingPropertyInfo, columnNameAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is ModelEnum modelEnum)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelEnum);

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Namespace")
                    , new DescriptionAttribute("Overrides default namespace")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.OutputDirectoryDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsOutputDirectoryTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Output Directory")
                    , new DescriptionAttribute("Overrides default output directory")
                    , new CategoryAttribute("Code Generation")
                    , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Beispiel #7
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelClass modelClass)
            {
                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelClass);

                storeDomainDataDirectory = modelClass.Store.DomainDataDirectory;



                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.DatabaseSchemaDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDatabaseSchemaTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Database Schema")
                    , new DescriptionAttribute("The schema to use for table creation. Overrides default schema for model if present.")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.NamespaceDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsNamespaceTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Namespace")
                    , new DescriptionAttribute("Overrides default namespace")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.OutputDirectoryDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsOutputDirectoryTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Output Directory")
                    , new DescriptionAttribute("Overrides default output directory")
                    , new CategoryAttribute("Code Generation")
                    , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelClass modelClass)
            {
                EFCoreValidator.RemoveHiddenProperties(propertyDescriptors, modelClass);

                storeDomainDataDirectory = modelClass.Store.DomainDataDirectory;

                //Add the descriptors for the tracking properties
                /********************************************************************************/

                DomainPropertyInfo databaseSchemaPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.DatabaseSchemaDomainPropertyId);
                DomainPropertyInfo isDatabaseSchemaTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDatabaseSchemaTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] databaseSchemaAttributes =
                {
                    new DisplayNameAttribute("Database Schema"),
                    new DescriptionAttribute("The schema to use for table creation. Overrides default schema for model if present."),
                    new CategoryAttribute("Database")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, databaseSchemaPropertyInfo, isDatabaseSchemaTrackingPropertyInfo, databaseSchemaAttributes));

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));

                /********************************************************************************/

                DomainPropertyInfo outputDirectoryPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.OutputDirectoryDomainPropertyId);
                DomainPropertyInfo isOutputDirectoryTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsOutputDirectoryTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] outputDirectoryAttributes =
                {
                    new DisplayNameAttribute("Output Directory"),
                    new DescriptionAttribute("Overrides default output directory"),
                    new CategoryAttribute("Code Generation"),
                    new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, outputDirectoryPropertyInfo, isOutputDirectoryTrackingPropertyInfo, outputDirectoryAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelAttribute modelAttribute)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;

                EFCoreValidator.RemoveHiddenProperties(propertyDescriptors, modelAttribute);

                // No sense asking for initial values if we won't use them
                if (!modelAttribute.SupportsInitialValue)
                {
                    PropertyDescriptor initialValueTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "InitialValue");
                    propertyDescriptors.Remove(initialValueTypeDescriptor);
                }

                // don't display IdentityType unless the IsIdentity is true
                if (!modelAttribute.IsIdentity)
                {
                    PropertyDescriptor identityTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "IdentityType");
                    propertyDescriptors.Remove(identityTypeDescriptor);
                }

                // ImplementNotify implicitly defines autoproperty as false, so we don't display it
                if (modelAttribute.ModelClass.ImplementNotify)
                {
                    PropertyDescriptor autoPropertyTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "AutoProperty");
                    propertyDescriptors.Remove(autoPropertyTypeDescriptor);
                }

                /********************************************************************************/

                // don't display String property modifiers unless the type is "String"
                if (modelAttribute.Type != "String")
                {
                    PropertyDescriptor minLengthTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "MinLength");
                    propertyDescriptors.Remove(minLengthTypeDescriptor);

                    PropertyDescriptor maxLengthTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "MaxLength");
                    propertyDescriptors.Remove(maxLengthTypeDescriptor);

                    PropertyDescriptor stringTypeTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "StringType");
                    propertyDescriptors.Remove(stringTypeTypeDescriptor);
                }

                /********************************************************************************/

                // don't display IndexedUnique unless the Indexed is true
                if (!modelAttribute.Indexed)
                {
                    PropertyDescriptor indexedUniqueTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "IndexedUnique");
                    propertyDescriptors.Remove(indexedUniqueTypeDescriptor);
                }

                /********************************************************************************/

                DomainPropertyInfo columnNamePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId);
                DomainPropertyInfo isColumnNameTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] columnNameAttributes =
                {
                    new DisplayNameAttribute("Column Name"),
                    new DescriptionAttribute("Overrides default column name"),
                    new CategoryAttribute("Database")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute, columnNamePropertyInfo, isColumnNameTrackingPropertyInfo, columnNameAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Beispiel #10
0
        /// <summary>
        ///    Returns the property descriptors for the described Association domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is Association association)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, association);

                // show FKPropertyName only when possible and required
                if (!association.Source.ModelRoot.ExposeForeignKeys ||
                    (association.SourceRole != EndpointRole.Dependent && association.TargetRole != EndpointRole.Dependent))
                {
                    propertyDescriptors.Remove("FKPropertyName");
                }

                // only display roles for 1..1 and 0-1..0-1 associations
                if ((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) &&
                    (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne))
                {
                    propertyDescriptors.Remove("SourceRole");
                    propertyDescriptors.Remove("TargetRole");
                }

                // only display delete behavior on the principal end
                if (association.SourceRole != EndpointRole.Principal)
                {
                    propertyDescriptors.Remove("SourceDeleteAction");
                }

                if (association.TargetRole != EndpointRole.Principal)
                {
                    propertyDescriptors.Remove("TargetDeleteAction");
                }

                // only show JoinTableName if is *..* association
                if (association.SourceMultiplicity != Multiplicity.ZeroMany || association.TargetMultiplicity != Multiplicity.ZeroMany)
                {
                    propertyDescriptors.Remove("JoinTableName");
                }

                /********************************************************************************/

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                       , storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Collection Class")
                    , new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model")
                    , new CategoryAttribute("Code Generation")
                }));

                if (association.TargetMultiplicity == Multiplicity.One || association.TargetMultiplicity == Multiplicity.ZeroOne)
                {
                    propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.TargetImplementNotifyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.IsTargetImplementNotifyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("Implement INotifyPropertyChanged")
                        , new DescriptionAttribute("Should this end participate in INotifyPropertyChanged activities? "
                                                   + "Only valid for non-collection targets.")
                        , new CategoryAttribute("End 2")
                    }));
                }

                if (association is BidirectionalAssociation bidirectionalAssociation && (bidirectionalAssociation.SourceMultiplicity == Multiplicity.One ||
                                                                                         bidirectionalAssociation.SourceMultiplicity == Multiplicity.ZeroOne))
                {
                    propertyDescriptors.Add(new TrackingPropertyDescriptor(bidirectionalAssociation
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.SourceImplementNotifyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.IsSourceImplementNotifyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("Implement INotifyPropertyChanged")
                        , new DescriptionAttribute("Should this end participate in INotifyPropertyChanged activities? "
                                                   + "Only valid for non-collection targets.")
                        , new CategoryAttribute("End 1")
                    }));
                }
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is Association association)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, association);

                // ImplementNotify implicitly defines autoproperty as false, so we don't display it
                // Similarly, collections are autoproperty == true, so no need to display it then either
                if ((association.Target.ImplementNotify || association.SourceMultiplicity == Multiplicity.ZeroMany) && association is BidirectionalAssociation)
                {
                    PropertyDescriptor sourceAutoPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "SourceAutoProperty");
                    if (sourceAutoPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(sourceAutoPropertyDescriptor);
                    }
                }

                if (association.Source.ImplementNotify || association.TargetMultiplicity == Multiplicity.ZeroMany)
                {
                    PropertyDescriptor targetAutoPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "TargetAutoProperty");
                    if (targetAutoPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(targetAutoPropertyDescriptor);
                    }
                }

                // only display roles for 1..1 and 0-1..0-1 associations
                if (((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) &&
                     (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne)))
                {
                    PropertyDescriptor sourceRolePropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "SourceRole");
                    if (sourceRolePropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(sourceRolePropertyDescriptor);
                    }

                    PropertyDescriptor targetRolePropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "TargetRole");
                    if (targetRolePropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(targetRolePropertyDescriptor);
                    }
                }

                // only display delete behavior on the principal end
                if (association.SourceRole != EndpointRole.Principal)
                {
                    PropertyDescriptor sourceDeleteActionPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "SourceDeleteAction");
                    if (sourceDeleteActionPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(sourceDeleteActionPropertyDescriptor);
                    }
                }

                if (association.TargetRole != EndpointRole.Principal)
                {
                    PropertyDescriptor targetDeleteActionPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "TargetDeleteAction");
                    if (targetDeleteActionPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(targetDeleteActionPropertyDescriptor);
                    }
                }

                /********************************************************************************/

                DomainPropertyInfo collectionClassPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId);
                DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] collectionClassAttributes =
                {
                    new DisplayNameAttribute("Collection Class"),
                    new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelAttribute modelAttribute)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelAttribute);

                // No sense asking for initial values if we won't use them
                if (!modelAttribute.SupportsInitialValue)
                {
                    propertyDescriptors.Remove("InitialValue");
                }

                // don't display IdentityType if IsIdentity is false
                if (!modelAttribute.IsIdentity)
                {
                    propertyDescriptors.Remove("IdentityType");
                }

                // if IsIdentity is true, since we don't encourage changing identity properties (!), don't show the implement notify switch
                if (modelAttribute.IsIdentity)
                {
                    propertyDescriptors.Remove("ImplementNotify");
                }

                // don't display SetterVisibility if IsIdentity is true and automatically generated
                if (modelAttribute.IsIdentity && modelAttribute.IdentityType == IdentityType.AutoGenerated)
                {
                    propertyDescriptors.Remove("SetterVisibility");
                }

                // ImplementNotify implicitly defines autoproperty as false, so we don't display it
                if (modelAttribute.ImplementNotify)
                {
                    propertyDescriptors.Remove("AutoProperty");
                }

                // this is about to be removed
                propertyDescriptors.Remove("PersistencePoint");

                // don't display String property modifiers unless the type is "String"
                if (modelAttribute.Type != "String")
                {
                    propertyDescriptors.Remove("MinLength");
                    propertyDescriptors.Remove("MaxLength");
                    propertyDescriptors.Remove("StringType");
                }

                // don't display IndexedUnique unless the Indexed is true
                if (!modelAttribute.Indexed)
                {
                    propertyDescriptors.Remove("IndexedUnique");
                }

                // don't display BackingField unless AutoProperty is false
                if (modelAttribute.AutoProperty)
                {
                    propertyDescriptors.Remove("BackingFieldName");
                }

                /********************************************************************************/

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Name")
                    , new DescriptionAttribute("Overrides default column name")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnTypeDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnTypeTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Type")
                    , new DescriptionAttribute("Overrides default column type")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.AutoPropertyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsAutoPropertyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("AutoProperty")
                    , new DescriptionAttribute("Overrides default autoproperty setting")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ImplementNotifyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsImplementNotifyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Implement INotifyPropertyChanged")
                    , new DescriptionAttribute("Should this attribute implement INotifyPropertyChanged?")
                    , new CategoryAttribute("Code Generation")
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelAttribute modelAttribute)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelAttribute);

                // No sense asking for initial values if we won't use them
                if (!modelAttribute.SupportsInitialValue)
                {
                    PropertyDescriptor initialValuePropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "InitialValue");

                    if (initialValuePropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(initialValuePropertyDescriptor);
                    }
                }

                // don't display IdentityType unless the IsIdentity is true
                if (!modelAttribute.IsIdentity)
                {
                    PropertyDescriptor identityPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "IdentityType");

                    if (identityPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(identityPropertyDescriptor);
                    }
                }

                // ImplementNotify implicitly defines autoproperty as false, so we don't display it
                if (modelAttribute.ModelClass.ImplementNotify)
                {
                    PropertyDescriptor autoPropertyPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "AutoProperty");

                    if (autoPropertyPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(autoPropertyPropertyDescriptor);
                    }
                }

                // don't need a persistence point type if it's not persistent
                if (!modelAttribute.Persistent)
                {
                    PropertyDescriptor persistencePointPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "PersistencePoint");

                    if (persistencePointPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(persistencePointPropertyDescriptor);
                    }
                }

                /********************************************************************************/

                // don't display String property modifiers unless the type is "String"
                if (modelAttribute.Type != "String")
                {
                    PropertyDescriptor minLengthPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "MinLength");

                    if (minLengthPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(minLengthPropertyDescriptor);
                    }

                    PropertyDescriptor maxLengthPropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "MaxLength");

                    if (maxLengthPropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(maxLengthPropertyDescriptor);
                    }

                    PropertyDescriptor stringTypePropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "StringType");

                    if (stringTypePropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(stringTypePropertyDescriptor);
                    }
                }

                /********************************************************************************/

                // don't display IndexedUnique unless the Indexed is true
                if (!modelAttribute.Indexed)
                {
                    PropertyDescriptor indexedUniquePropertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == "IndexedUnique");

                    if (indexedUniquePropertyDescriptor != null)
                    {
                        propertyDescriptors.Remove(indexedUniquePropertyDescriptor);
                    }
                }

                /********************************************************************************/

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Name")
                    , new DescriptionAttribute("Overrides default column name")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnTypeDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnTypeTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Type")
                    , new DescriptionAttribute("Overrides default column type")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.AutoPropertyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsAutoPropertyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("AutoProperty")
                    , new DescriptionAttribute("Overrides default autoproperty setting")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ImplementNotifyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsImplementNotifyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Implement INotifyPropertyChanged")
                    , new DescriptionAttribute("Should this attribute implement INotifyPropertyChanged?")
                    , new CategoryAttribute("Code Generation")
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Beispiel #14
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelAttribute modelAttribute)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;
                ModelRoot modelRoot = modelAttribute.ModelClass.ModelRoot;

                // keyless classes don't get identities
                if (modelAttribute.ModelClass.IsKeylessType())
                {
                    propertyDescriptors.Remove("IsIdentity");
                    propertyDescriptors.Remove("IdentityType");
                }

                // No sense asking for initial values if we won't use them
                if (!modelAttribute.SupportsInitialValue)
                {
                    propertyDescriptors.Remove("InitialValue");
                }

                // don't display IdentityType if IsIdentity is false
                if (!modelAttribute.IsIdentity)
                {
                    propertyDescriptors.Remove("IdentityType");
                }

                // if IsIdentity is true, since we don't encourage changing identity properties (!), don't show the implement notify switch
                if (modelAttribute.IsIdentity)
                {
                    propertyDescriptors.Remove("ImplementNotify");
                }

                // don't display SetterVisibility if IsIdentity is true and automatically generated
                if (modelAttribute.IsIdentity && modelAttribute.IdentityType == IdentityType.AutoGenerated)
                {
                    propertyDescriptors.Remove("SetterVisibility");
                }

                // ImplementNotify implicitly defines autoproperty as false, so we don't display it
                if (modelAttribute.ImplementNotify)
                {
                    propertyDescriptors.Remove("AutoProperty");
                }

                if (modelAttribute.Type != "String")
                {
                    // don't display String property modifiers unless the type is "String"
                    propertyDescriptors.Remove("MinLength");
                    propertyDescriptors.Remove("MaxLength");
                    propertyDescriptors.Remove("StringType");
                }

                // don't display IndexedUnique unless the Indexed is true
                if (!modelAttribute.Indexed)
                {
                    propertyDescriptors.Remove("IndexedUnique");
                }

                // EF6 doesn't support various attribute features
                if (modelRoot.EntityFrameworkVersion == EFVersion.EF6)
                {
                    propertyDescriptors.Remove("PropertyAccessMode");
                }

                // don't display BackingField or PropertyAccessMode unless AutoProperty is false
                if (modelAttribute.AutoProperty)
                {
                    propertyDescriptors.Remove("BackingFieldName");
                    propertyDescriptors.Remove("PropertyAccessMode");
                }

                // only abstract classes can have abstract properties
                if (!modelAttribute.ModelClass.IsAbstract)
                {
                    propertyDescriptors.Remove("IsAbstract");
                }

                // abstract properties don't get lots of stuff
                if (modelAttribute.IsAbstract)
                {
                    propertyDescriptors.Remove("IsIdentity");
                    propertyDescriptors.Remove("IdentityType");
                    propertyDescriptors.Remove("AutoProperty");
                    propertyDescriptors.Remove("InitialValue");
                    propertyDescriptors.Remove("BackingFieldName");
                    propertyDescriptors.Remove("PropertyAccessMode");
                    propertyDescriptors.Remove("Indexed");
                    propertyDescriptors.Remove("IndexedUnique");
                }

                /********************************************************************************/

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Name")
                    , new DescriptionAttribute("Overrides default column name")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnTypeDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnTypeTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Column Type")
                    , new DescriptionAttribute("Overrides default column type")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.AutoPropertyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsAutoPropertyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("AutoProperty")
                    , new DescriptionAttribute("Overrides default autoproperty setting")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ImplementNotifyDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsImplementNotifyTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Implement INotifyPropertyChanged")
                    , new DescriptionAttribute("Should this attribute implement INotifyPropertyChanged?")
                    , new CategoryAttribute("Code Generation")
                }));

                if (modelRoot.IsEFCore5Plus)
                {
                    if (modelAttribute.Type == "String")
                    {
                        propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                               , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.DatabaseCollationDomainPropertyId)
                                                                               , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsDatabaseCollationTrackingDomainPropertyId)
                                                                               , new Attribute[]
                        {
                            new DisplayNameAttribute("Database Collation")
                            , new DescriptionAttribute("Overrides the default database collation setting for the column that persists this attribute")
                            , new CategoryAttribute("Database")
                        }));
                    }

                    propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute
                                                                           , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.PropertyAccessModeDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsPropertyAccessModeTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("Property Access Mode")
                        , new DescriptionAttribute("Defines how EF reads and write this property or its backing field. See  https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.propertyaccessmode")
                        , new CategoryAttribute("Code Generation")
                    }));
                }
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelClass modelClass)
            {
                storeDomainDataDirectory = modelClass.Store.DomainDataDirectory;
                ModelRoot modelRoot = modelClass.ModelRoot;

                // things unavailable if pre-EFCore5
                if (!modelRoot.IsEFCore5Plus)
                {
                    propertyDescriptors.Remove("IsPropertyBag");
                    propertyDescriptors.Remove("IsQueryType");
                    propertyDescriptors.Remove("ExcludeFromMigrations");
                    propertyDescriptors.Remove("IsDatabaseView");
                    propertyDescriptors.Remove("ViewName");

                    if (modelClass.IsDependentType && modelRoot.EntityFrameworkVersion == EFVersion.EF6)
                    {
                        propertyDescriptors.Remove("TableName");
                    }
                }
                else
                {
                    if (modelClass.IsQueryType)
                    {
                        propertyDescriptors.Remove("TableName");
                        propertyDescriptors.Remove("DatabaseSchema");
                        propertyDescriptors.Remove("Concurrency");
                    }

                    if (modelClass.IsDatabaseView)
                    {
                        propertyDescriptors.Remove("TableName");
                    }
                    else
                    {
                        propertyDescriptors.Remove("ViewName");
                    }

                    if (modelClass.IsPropertyBag)
                    {
                        propertyDescriptors.Remove("IsDependentType");
                    }
                }

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.AutoPropertyDefaultDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsAutoPropertyDefaultTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("AutoProperty Default")
                    , new DescriptionAttribute("Overrides default autoproperty default setting")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.DatabaseSchemaDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDatabaseSchemaTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Database Schema")
                    , new DescriptionAttribute("The schema to use for table creation. Overrides default schema for model if present.")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.NamespaceDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsNamespaceTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Namespace")
                    , new DescriptionAttribute("Overrides default namespace")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.DefaultConstructorVisibilityDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDefaultConstructorVisibilityTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Default Constructor Visibility")
                    , new DescriptionAttribute("By default, default (empty) constructors generate as public unless there are required properties or associations in the entity, then they generate as protected.")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.OutputDirectoryDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsOutputDirectoryTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Output Directory")
                    , new DescriptionAttribute("Overrides default output directory")
                    , new CategoryAttribute("Code Generation")
                    , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
        /// <summary>
        ///    Returns the property descriptors for the described Association domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is Association association)
            {
                ModelRoot modelRoot = association.Source.ModelRoot;
                storeDomainDataDirectory = association.Store.DomainDataDirectory;
                BidirectionalAssociation bidirectionalAssociation = association as BidirectionalAssociation;

                // show FKPropertyName only when possible and required
                if (!modelRoot.ExposeForeignKeys ||
                    (association.SourceRole != EndpointRole.Dependent && association.TargetRole != EndpointRole.Dependent))
                {
                    propertyDescriptors.Remove("FKPropertyName");
                }

                // EF6 can't have declared foreign keys for 1..1 / 0-1..1 / 1..0-1 / 0-1..0-1 relationships
                if (modelRoot.EntityFrameworkVersion == EFVersion.EF6 &&
                    association.SourceMultiplicity != Multiplicity.ZeroMany &&
                    association.TargetMultiplicity != Multiplicity.ZeroMany)
                {
                    propertyDescriptors.Remove("FKPropertyName");
                }

                // no FKs for aggregates
                if (association.Source.IsDependentType || association.Target.IsDependentType)
                {
                    propertyDescriptors.Remove("FKPropertyName");
                }

                // only display roles for 1..1 and 0-1..0-1 associations
                if ((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) &&
                    (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne))
                {
                    propertyDescriptors.Remove("SourceRole");
                    propertyDescriptors.Remove("TargetRole");
                }

                // only display delete behavior on the principal end
                // except that owned types don't have deletiion behavior choices
                if (association.SourceRole != EndpointRole.Principal || association.Source.IsDependentType || association.Target.IsDependentType)
                {
                    propertyDescriptors.Remove("SourceDeleteAction");
                }

                if (association.TargetRole != EndpointRole.Principal || association.Source.IsDependentType || association.Target.IsDependentType)
                {
                    propertyDescriptors.Remove("TargetDeleteAction");
                }

                // only show JoinTableName if is *..* association
                if (association.SourceMultiplicity != Multiplicity.ZeroMany || association.TargetMultiplicity != Multiplicity.ZeroMany)
                {
                    propertyDescriptors.Remove("JoinTableName");
                }

                // implementNotify implicitly defines autoproperty as false, so we don't display it
                if (association.TargetImplementNotify)
                {
                    propertyDescriptors.Remove("TargetAutoProperty");
                }
                if (bidirectionalAssociation != null && bidirectionalAssociation.SourceImplementNotify)
                {
                    propertyDescriptors.Remove("SourceAutoProperty");
                }

                // we're only allowing ..1 and ..0-1 associations to have backing fields
                if (association.TargetMultiplicity == Multiplicity.ZeroMany)
                {
                    propertyDescriptors.Remove("TargetAutoProperty");
                }
                if (bidirectionalAssociation != null && bidirectionalAssociation.SourceMultiplicity == Multiplicity.ZeroMany)
                {
                    propertyDescriptors.Remove("SourceAutoProperty");
                }

                // EF6 doesn't support property access modes
                if (modelRoot.EntityFrameworkVersion == EFVersion.EF6)
                {
                    propertyDescriptors.Remove("TargetPropertyAccessMode");
                    propertyDescriptors.Remove("SourcePropertyAccessMode");
                }

                // only show backing field name and property access mode if not an autoproperty
                if (association.TargetAutoProperty)
                {
                    propertyDescriptors.Remove("TargetBackingFieldName");
                    propertyDescriptors.Remove("TargetPropertyAccessMode");
                }

                if (bidirectionalAssociation == null || bidirectionalAssociation.SourceAutoProperty)
                {
                    propertyDescriptors.Remove("SourceBackingFieldName");
                    propertyDescriptors.Remove("SourcePropertyAccessMode");
                }

                /********************************************************************************/

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                       , storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Collection Class")
                    , new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model")
                    , new CategoryAttribute("Code Generation")
                }));

                if (association.TargetMultiplicity == Multiplicity.One || association.TargetMultiplicity == Multiplicity.ZeroOne)
                {
                    propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.TargetImplementNotifyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.IsTargetImplementNotifyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("Implement INotifyPropertyChanged")
                        , new DescriptionAttribute("Should this end participate in INotifyPropertyChanged activities? "
                                                   + "Only valid for non-collection targets.")
                        , new CategoryAttribute("End 2")
                    }));

                    propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.TargetAutoPropertyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(Association.IsTargetAutoPropertyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("End1 Is Auto Property")
                        , new DescriptionAttribute("If false, generates a backing field and a partial method to hook getting and setting the property. "
                                                   + "If true, generates a simple auto property. Only valid for non-collection properties.")
                        , new CategoryAttribute("End 2")
                    }));
                }

                if (bidirectionalAssociation?.SourceMultiplicity == Multiplicity.One || bidirectionalAssociation?.SourceMultiplicity == Multiplicity.ZeroOne)
                {
                    propertyDescriptors.Add(new TrackingPropertyDescriptor(bidirectionalAssociation
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.SourceImplementNotifyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.IsSourceImplementNotifyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("Implement INotifyPropertyChanged")
                        , new DescriptionAttribute("Should this end participate in INotifyPropertyChanged activities? "
                                                   + "Only valid for non-collection targets.")
                        , new CategoryAttribute("End 1")
                    }));

                    propertyDescriptors.Add(new TrackingPropertyDescriptor(association
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.SourceAutoPropertyDomainPropertyId)
                                                                           , storeDomainDataDirectory.GetDomainProperty(BidirectionalAssociation.IsSourceAutoPropertyTrackingDomainPropertyId)
                                                                           , new Attribute[]
                    {
                        new DisplayNameAttribute("End2 Is Auto Property")
                        , new DescriptionAttribute("If false, generates a backing field and a partial method to hook getting and setting the property. "
                                                   + "If true, generates a simple auto property. Only valid for non-collection properties.")
                        , new CategoryAttribute("End 1")
                    }));
                }
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }