private static void FixUpModelContext(MetaModel model)
        {
            ModelContext modelContext = new ModelContext(model.Store);
            modelContext.Name = "DefaultContext";
            modelContext.IsDefault = true;
            model.ModelContexts.Add(modelContext);

            DomainClass domainClass = new DomainClass(model.Store);
            domainClass.Name = "DomainModel";
            domainClass.IsDomainModel = true;
            domainClass.DisplayName = "DomainModel";
            domainClass.SerializationName = "DomainModel";
            modelContext.Classes.Add(domainClass);
        }
        private static void FixUpSerializedDomainModel(ModelContext model)
        {
            foreach (DomainClass domainClass in model.Classes)
                if (domainClass.IsDomainModel)
                {
                    SerializedDomainModel child = new SerializedDomainModel(domainClass.Store);
                    child.DomainClass = domainClass;
                    child.SerializationName = domainClass.SerializationName;

                    model.SerializationModel.SerializedDomainModel = child;
                    SerializationHelper.AddSerializationDomainProperties(domainClass.Store, domainClass);
                }
                else
                {
                    SerializationDomainClassAddRule.OnDomainClassAdded(domainClass);
                    domainClass.SerializedDomainClass.SerializationName = domainClass.SerializationName;
                }

            foreach (DomainRelationship relationship in model.Relationships)
            {
                if (relationship is EmbeddingRelationship)
                {
                    SerializationDomainRelationshipAddRule.OnEmbeddingRelationshipAdded(relationship as EmbeddingRelationship);
                    (relationship as EmbeddingRelationship).SerializedEmbeddingRelationship.SerializationName = relationship.SerializationName;
                }
                else
                {
                    SerializationDomainRelationshipAddRule.OnReferenceRelationshipAdded(relationship as ReferenceRelationship);
                    (relationship as ReferenceRelationship).SerializedReferenceRelationship.SerializationName = relationship.SerializationName;
                }
            }

            foreach (DomainClass domainClass in model.Classes)
            {
                SerializationHelper.UpdateSerializationDomainProperties(domainClass.Store, domainClass.SerializedDomainClass, domainClass);
                SerializationHelper.UpdateSerializationDomainRoles(domainClass.Store, domainClass.SerializedDomainClass, domainClass);

                foreach (DomainProperty p in domainClass.Properties)
                    p.SerializedDomainProperty.IsSerializationNameTracking = TrackingEnum.True;
            }

            foreach (DomainRelationship relationship in model.Relationships)
            {
                if (relationship is EmbeddingRelationship)
                {
                    SerializationHelper.UpdateSerializationDomainProperties(relationship.Store, (relationship as EmbeddingRelationship).SerializedEmbeddingRelationship, relationship);
                }
                else
                {
                    SerializationHelper.UpdateSerializationDomainProperties(relationship.Store, (relationship as ReferenceRelationship).SerializedReferenceRelationship, relationship);
                }

                foreach (DomainProperty p in relationship.Properties)
                    p.SerializedDomainProperty.IsSerializationNameTracking = TrackingEnum.True;
            }

            // correct IsSerializationNameTracking values

            foreach (DomainClass domainClass in model.Classes)
            {
                if (domainClass.SerializationName != domainClass.Name)
                    domainClass.IsSerializationNameTracking = TrackingEnum.False;

                domainClass.SerializedDomainClass.IsSerializationNameTracking = domainClass.IsSerializationNameTracking;

                foreach (DomainProperty p in domainClass.Properties)
                {
                    if (p.Name != p.SerializationName)
                        p.IsSerializationNameTracking = TrackingEnum.False;

                    p.SerializedDomainProperty.IsSerializationNameTracking = p.IsSerializationNameTracking;

                    if (p.Name == "DomainFilePath")
                        p.SerializedDomainProperty.OmitProperty = true;
                }
            }

            foreach (DomainRelationship relationship in model.Relationships)
            {
                if (relationship is EmbeddingRelationship)
                {
                    EmbeddingRelationship emb = relationship as EmbeddingRelationship;
                    if (emb.SerializationName != emb.Name)
                        emb.IsSerializationNameTracking = TrackingEnum.False;

                    emb.SerializedEmbeddingRelationship.IsSerializationNameTracking = emb.IsSerializationNameTracking;
                }
                else
                {
                    ReferenceRelationship refRel = relationship as ReferenceRelationship;
                    if (refRel.SerializationName != refRel.Name)
                        refRel.IsSerializationNameTracking = TrackingEnum.False;

                    refRel.SerializedReferenceRelationship.IsSerializationNameTracking = refRel.IsSerializationNameTracking;
                }

                foreach (DomainProperty p in relationship.Properties)
                {
                    if (p.Name != p.SerializationName)
                        p.IsSerializationNameTracking = TrackingEnum.True;

                    p.SerializedDomainProperty.IsSerializationNameTracking = p.IsSerializationNameTracking;
                }
            }
        }