Exemple #1
0
        private async Task <IBunqEntity[]> GetResponseObjectsAsync(HttpResponseMessage responseMessage, string content)
        {
            var responseObject = JObject.Parse(await responseMessage.Content.ReadAsStringAsync());
            var responseArray  = (JArray)((JProperty)responseObject.First).Value;

            if (responseMessage.StatusCode != HttpStatusCode.OK)
            {
                var error = responseArray.First.ToObject <Error>();

                throw new BunqApiException(error);
            }

            var responseObjects = new List <IBunqEntity>();

            foreach (var element in responseArray.Cast <JObject>())
            {
                var property      = (JProperty)element.First;
                var propertyValue = (JObject)property.Value;

                var type = ModelFinder.FindByName(property.Name);

                responseObjects.Add((IBunqEntity)propertyValue.ToObject(type));
            }

            return(responseObjects.ToArray());
        }
Exemple #2
0
        private static void LoadModels(ServiceProvider serviceProvider)
        {
            ExistingModels existingModels = serviceProvider.GetService <ExistingModels>();
            ModelFinder    modelFinder    = serviceProvider.GetService <ModelFinder>();

            existingModels.Load(modelFinder.GetModels());
        }
        public async Task <string> Add <T>() where T : BaseEntity, new()
        {
            IServiceProvider    sp          = StartUp.ServiceProvider;
            IBaseRepository <T> repo        = sp.GetService <IBaseRepository <T> >();
            IModelFinder <T>    modelFinder = new ModelFinder() as IModelFinder <T>;
            T      model = modelFinder.GetModel();
            string Id    = await repo.Add(model);

            Assert.IsNotNull(Id);
            return(Id);
        }
        static void Main(string[] args)
        {
            const string tnameTest = "Test6 Tenant";
            const string mnameTest = "Test6 Model";

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;
                Console.WriteLine("LazyLoadingEnabled: " + ctxTarget.Configuration.LazyLoadingEnabled.ToString());
                //ctx.Configuration.LazyLoadingEnabled = false;
                //Console.WriteLine("LazyLoadingEnabled: " + ctx.Configuration.LazyLoadingEnabled.ToString());

                ModelMigrator.PreloadAllTables(ctxTarget);

                var tTarget = ModelFinder.FindTenant(ctxTarget, null, tnameTest);
                //var tenants = ModelFinder.FindTenants(ctx, null, tnameTest);
                //var tenant = tenants.ElementAt<tenant>(0);
                Console.WriteLine("tenant.identifier: " + tTarget.identifier);

                var models  = ModelFinder.FindModels(ctxTarget, tTarget, null, mnameTest);
                var mTarget = models.ElementAt <model>(0);
                Console.WriteLine("model.identifier: " + mTarget.identifier);
                var model0 = ModelFinder.FindModel(ctxTarget, tTarget, null, mnameTest);
                Console.WriteLine("model0.identifier: " + model0.identifier);

                string  modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd";
                DataSet dsModel         = new DataSet();
                dsModel.ReadXmlSchema(modelSchemaFile);
                dsModel.Tables["element"].MinimumCapacity      = ctxTarget.element.Count();
                dsModel.Tables["properties"].MinimumCapacity   = ctxTarget.properties.Count();
                dsModel.Tables["property"].MinimumCapacity     = ctxTarget.property.Count();
                dsModel.Tables["value"].MinimumCapacity        = ctxTarget.value.Count();
                dsModel.Tables["relationship"].MinimumCapacity = ctxTarget.relationship.Count();

                var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet);
                mmpModel.ProcessModel(dsModel, (DbContext)ctxTarget, new Collection <model> {
                    model0
                });
                //dsModel.WriteXml("model0ds.xml", XmlWriteMode.IgnoreSchema);
                string filename = "model7archi.xml";
                mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename);

                ctxTarget.SaveChanges();
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            const string tTargetName       = "Tenant 2 Test";
            string       tTargetIdentifier = Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, Util.TrimWhitespace(tTargetName));

            const string mTargetName       = "Model 2 Test";
            string       mTargetIdentifier = Util.MakeIdentifierFromParentIdentifier(
                Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, tTargetName),
                typeof(model).Name, Util.TrimWhitespace(mTargetName));

            tenant tTarget = null;
            model  mTarget = null;

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                folders fs0 = tTarget.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                string  modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd";
                DataSet dsModel         = new DataSet();
                dsModel.ReadXmlSchema(modelSchemaFile);
                //DataSet ds3 = dsModel.Copy();
                //var mmpModel = new ModelMateProcessor();
                var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet);
                mmpModel.ProcessModel(dsModel, (DbContext)ctxTarget, new Collection <model> {
                    mTarget
                });
                //dsModel.WriteXml("modelds.xml", XmlWriteMode.IgnoreSchema);
                string filename = "model4archi.xml";
                mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename);

                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            using (var ctx = new ModelMateEFModel9Context())
            {
                ctx.Database.Log = Console.Write;
                Console.WriteLine("LazyLoadingEnabled: " + ctx.Configuration.LazyLoadingEnabled.ToString());

                foreach (tenant t in ctx.tenant)
                {
                    ModelDump.DisplayDBPropertyValues("t", ctx.Entry(t).CurrentValues, null);
                }

                //var query = from t in ctx.tenant
                //            where t.identifier == tident1
                //            select t;
                //tenant tq = query.Single();

                //object[] keysq = { tid };
                //tenant tq = ctx.tenant.Find(keysq);

                //ctx.Entry(tq).Collection(fs => fs.folders).Load(); // Works
                //folders fsq = tq.folders.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fsq", ctx.Entry(fsq).CurrentValues, null);

                //ctx.Entry(fsq).Collection(f => f.folder).Load(); // Works
                //folder fq = fsq.folder.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fq", ctx.Entry(fq).CurrentValues, null);

                //ctx.tenant.Load();
                object[] keys    = { tid };
                tenant   tenant9 = ctx.tenant.Find(keys);
                folders  fs0     = tenant9.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null);



                //folders fs0 = t0.folders.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null);
                //folder f0 = fs0.folder.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null);

                tenant[] ts2 = new tenant[] { };
                ts2 = ModelFinder.FindTenants(ctx, tident2, "");
                ModelDump.DisplayDBPropertyValues("ts2", ctx.Entry(ts2[0]).CurrentValues, null);

                ts2 = ModelFinder.FindTenants(ctx, "", tname2);
                ModelDump.DisplayDBPropertyValues("ts2", ctx.Entry(ts2[0]).CurrentValues, null);

                tenant t2 = null;
                try
                {
                    t2 = ModelFinder.FindTenant(ctx, "", tname1);
                    ModelDump.DisplayDBPropertyValues("t1", ctx.Entry(t2).CurrentValues, null);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EXCEPTION: " + ex.ToString());
                }

                //tenant t2 = null;
                try
                {
                    t2 = ModelFinder.FindTenant(ctx, tident1, "");
                    ModelDump.DisplayDBPropertyValues("t1", ctx.Entry(t2).CurrentValues, null);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EXCEPTION: " + ex.ToString());
                }

                model m2 = ModelFinder.FindModel(ctx, t2, mident0, null);
                ModelDump.DisplayDBPropertyValues("m2", ctx.Entry(m2).CurrentValues, null);

                element[] es0 = ModelFinder.FindElements(ctx, t2, m2, ModelConst.ElementType.ApplicationComponent);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                es0 = ModelFinder.FindElements(ctx, t2, m2, ModelConst.ElementType.AllElementTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                relationship[] rs0 = ModelFinder.FindRelationships(ctx, t2, m2, ModelConst.RelationshipType.AllRelationshipTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                foreach (relationship r in rs0)
                {
                    element eSource = ModelFinder.FindElement(ctx, t2, m2, r.source, null);
                    element eTarget = ModelFinder.FindElement(ctx, t2, m2, r.target, null);
                    ModelDump.DisplayDBPropertyValues("eSource", ctx.Entry(eSource).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("r", ctx.Entry(r).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("eTarget", ctx.Entry(eTarget).CurrentValues, null);
                }

                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            const string tTargetName = "Test6 Tenant";
            const string mTargetName = "Test6 Model";

            string tSourceName = tTargetName;
            string mSourceName = mTargetName;

            //DirectoryInfo di = new DirectoryInfo(@"..\..\MyUsers4ModelMate");
            DirectoryInfo di = new DirectoryInfo(@"..\..\Test Assemblies");
            //DirectoryInfo di = new DirectoryInfo(@"..\..\Web Assemblies");

            string test1 = "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

            //"System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

            //"System.Collections.Generic.IDictionary`2<System.String,System.Data.Entity.Infrastructure.Annotations.AnnotationValues> System.Data.Entity.Migrations.Model.AlterTableOperation::_annotations";

            //"System.Collections.Generic.IDictionary`2<System.String,System.Data.Entity.Infrastructure.Annotations.AnnotationValues> System.Data.Entity.Migrations.Model.AlterTableOperation::_annotations";

            //"System.Data.Entity.DbSet`1<VetContext1.DataModel1.AnimalType>";

            string test1Namespace  = Cecil2ModelMate.GetNamespaceFromFQName(test1);
            string test1Name       = Cecil2ModelMate.GetNameFromFQName(test1);
            string test1ObjectType = Cecil2ModelMate.DetermineArchiMateObjectType(test1).ToString();

            Console.WriteLine("test1: " + test1);
            Console.WriteLine("test1Namespace: " + test1Namespace);
            Console.WriteLine("test1Name: " + test1Name);
            Console.WriteLine("test1ObjectType: " + test1ObjectType);
            test1ObjectType = Cecil2ModelMate.DetermineArchiMateObjectType(test1Name).ToString();
            Console.WriteLine("test1ObjectType: " + test1ObjectType);
            test1ObjectType = Cecil2ModelMate.DetermineArchiMateObjectType(test1Namespace).ToString();
            Console.WriteLine("test1ObjectType: " + test1ObjectType);

            //test1 = "a.b.c.d";
            //test1Name = Cecil2ModelMate.GetNameFromFQName(test1);
            //test1Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test1);
            //Console.WriteLine("test1: " + test1);
            //Console.WriteLine("test1Namespace: " + test1Namespace);
            //Console.WriteLine("test1Name: " + test1Name);

            //string test2 = "System.Data.Entity.DbSet`1<VetContext1.DataModel1.AnimalType>";
            //string test2Name = Cecil2ModelMate.DetermineArchiMateObjectType(test2).ToString();
            //Console.WriteLine("test2: " + test2);
            //Console.WriteLine("test2Name: " + test2Name);

            //test2 = "System.Data.Entity.DbSet`1";
            //test2Name = Cecil2ModelMate.DetermineArchiMateObjectType(test2).ToString();
            //Console.WriteLine("test2: " + test2);
            //Console.WriteLine("test2Name: " + test2Name);

            //string test3 = "System.Data.Entity.Infrastructure.Interception.MutableInterceptionContext`1<TResult>";
            //string test3Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test3);
            //string test3Name = Cecil2ModelMate.DetermineArchiMateInterfaceType(test3).ToString();
            //Console.WriteLine("test3: " + test3);
            //Console.WriteLine("test3Namespace: " + test3Namespace);
            //Console.WriteLine("test3Name: " + test3Name);

            //test3 = "System.Data";
            //test3Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test3);
            //test3Name = Cecil2ModelMate.DetermineArchiMateInterfaceType(test3).ToString();
            //Console.WriteLine("test3: " + test3);
            //Console.WriteLine("test3Namespace: " + test3Namespace);
            //Console.WriteLine("test3Name: " + test3Name);

            //test3 = "System";
            //test3Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test3);
            //test3Name = Cecil2ModelMate.DetermineArchiMateInterfaceType(test3).ToString();
            //Console.WriteLine("test3: " + test3);
            //Console.WriteLine("test3Namespace: " + test3Namespace);
            //Console.WriteLine("test3Name: " + test3Name);

            //test3 = "S";
            //test3Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test3);
            //test3Name = Cecil2ModelMate.DetermineArchiMateInterfaceType(test3).ToString();
            //Console.WriteLine("test3: " + test3);
            //Console.WriteLine("test3Namespace: " + test3Namespace);
            //Console.WriteLine("test3Name: " + test3Name);

            //test3 = "";
            //test3Namespace = Cecil2ModelMate.GetNamespaceFromFQName(test3);
            //test3Name = Cecil2ModelMate.DetermineArchiMateInterfaceType(test3).ToString();
            //Console.WriteLine("test3: " + test3);
            //Console.WriteLine("test3Namespace: " + test3Namespace);
            //Console.WriteLine("test3Name: " + test3Name);

            model mSource = Cecil2ModelMate.Migrate2ModelMate(tSourceName, mSourceName, di);

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                //var oldLog = ctxTarget.Database.Log;
                //ctxTarget.Database.Log = Console.Write;

                Console.WriteLine("propertydefs.Count: " + ctxTarget.propertydefs.Local.Count().ToString());

                ModelMigrator.PreloadAllTables(ctxTarget);

                var tTarget = ModelFinder.FindTenant(ctxTarget, null, tTargetName);
                //var tenants = ModelFinder.FindTenants(ctxTarget, null, tnameTest);
                //var tenant = tenants.ElementAt<tenant>(0);
                Console.WriteLine("tenant.identifier: " + tTarget.identifier);

                folders fs0 = tTarget.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null);

                var models  = ModelFinder.FindModels(ctxTarget, tTarget, null, mTargetName);
                var mTarget = models.ElementAt <model>(0);
                Console.WriteLine("model.identifier: " + mTarget.identifier);
                var model0 = ModelFinder.FindModel(ctxTarget, tTarget, null, mTargetName);
                Console.WriteLine("model0.identifier: " + model0.identifier);

                ModelMigrator.MigrateModel(ctxTarget, tTarget, f0,
                                           mSource, PCOOperation.merge, PCOOperation.merge, true);

                string  modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd";
                DataSet dsModel         = new DataSet();
                dsModel.ReadXmlSchema(modelSchemaFile);
                var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet);
                mmpModel.ProcessModel(dsModel, (DbContext)ctxTarget, new Collection <model> {
                    model0
                });
                //dsModel.WriteXml("model0ds.xml", XmlWriteMode.IgnoreSchema);
                string filename = "model8archi.xml";
                mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename);

                //ctxTarget.Database.Log = oldLog;
                ctxTarget.SaveChanges();
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            const string tTargetName       = "Tenant 2 Test";
            string       tTargetIdentifier = Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, Util.TrimWhitespace(tTargetName));

            const string mTargetName       = "Model 2 Test";
            string       mTargetIdentifier = Util.MakeIdentifierFromParentIdentifier(
                Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, tTargetName),
                typeof(model).Name, Util.TrimWhitespace(mTargetName));

            tenant tTarget = null;
            model  mTarget = null;

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;
                Console.WriteLine("LazyLoadingEnabled: " + ctxTarget.Configuration.LazyLoadingEnabled.ToString());

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                element[] es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.ApplicationComponent);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.AllElementTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                relationship[] rs0 = ModelFinder.FindRelationships(ctxTarget, tTarget, mTarget, ModelConst.RelationshipType.AllRelationshipTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                foreach (relationship r in rs0)
                {
                    element eSource = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.source, null);
                    element eTarget = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.target, null);
                    ModelDump.DisplayDBPropertyValues("eSource", ctxTarget.Entry(eSource).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("r", ctxTarget.Entry(r).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("eTarget", ctxTarget.Entry(eTarget).CurrentValues, null);
                }
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            string tSourceName = "Tenant 2";

            ModelFactory.TenantName = tSourceName;

            string mSourceIdentifier = mTargetIdentifier;
            string mSourceName       = mTargetName; // "Model 2 " + DateTime.Now.ToString();

            ModelFactory.ModelName = mSourceName;

            tenant tSource = null;
            model  mSource = null;

            propertydef pdef1 = ModelFactory.NewPropertyDef("String Propertydef 1", ModelConst.PropertyDataType.stringType);
            propertydef pdef2 = ModelFactory.NewPropertyDef("Boolean Propertydef 2", ModelConst.PropertyDataType.booleanType);
            propertydef pdef3 = ModelFactory.NewPropertyDef("Number Propertydef 3", ModelConst.PropertyDataType.numberType);

            propertydef[] pdfArray = new propertydef[] { pdef1, pdef2, pdef3 };
            propertydefs  pdefs    = ModelFactory.NewPropertyDefs(pdfArray);

            ModelConst.ElementType etAC = ModelConst.ElementType.ApplicationComponent;
            element[] elementArray      = new element[10];
            for (int iElement = 0; iElement < 10; iElement++)
            {
                property p1 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()),
                                                       pdfArray[iElement % 3]);
                property p2 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()),
                                                       pdfArray[(iElement + 1) % 3]);
                properties ps = ModelFactory.NewProperties(new property[] { p1, p2 });
                elementArray[iElement] = ModelFactory.NewElement("Element " + iElement.ToString(), etAC, ps);
            }
            elements elements = ModelFactory.NewElements(elementArray);

            tSource = ModelFactory.NewTenant(tSourceName,
                                             ModelFactory.NewFolder("/",
                                                                    mSource = ModelFactory.NewModel(mSourceName, ModelConst.LANG_EN,
                                                                                                    elements, pdefs
                                                                                                    )
                                                                    )
                                             );

            mSource.version = "9.0";

            var properties = ModelFactory.NewProperties(ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Value 1"), pdef1));

            mSource.properties.Add(properties);

            //var name = ModelFactory.NewName("Model 2 Name " + DateTime.Now.ToString());
            //model3.name.Add(name);

            var relationship1 = ModelFactory.NewRelationship("Association Relationship 1",
                                                             ModelConst.RelationshipType.AssociationRelationship,
                                                             elementArray[0], elementArray[1]
                                                             );
            var relationship2 = ModelFactory.NewRelationship("Association Relationship 2",
                                                             ModelConst.RelationshipType.AssociationRelationship,
                                                             elementArray[2], elementArray[3]
                                                             );
            var relationships = ModelFactory.NewRelationships(new relationship[] { relationship1, relationship2 });

            mSource.relationships.Add(relationships);

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            //var organization = ModelFactory.NewOrganization(
            //            ModelFactory.NewItem(elementArray[0],
            //                ModelFactory.NewItem(null,
            //                    ModelFactory.NewItem(elementArray[1]
            //                    )
            //                )
            //            )
            //       );
            //model3.organization.Add(organization);

            //var documentation = ModelFactory.NewDocumentation("Model 2 Documentation " + DateTime.Now.ToString());
            //model3.documentation.Add(documentation);

            //var metadata = ModelFactory.NewMetadata(
            //            ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Metadata Value " + DateTime.Now.ToString()), pdefString)
            //        );
            //model3.metadata.Add(metadata);

            //var style1 = ModelFactory.NewStyle(
            //                ModelFactory.NewFillColor(255, 0, 0),
            //                ModelFactory.NewLineColor(0, 255, 0),
            //                ModelFactory.NewFont("Times Roman", (float)10.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
            //            );
            //var style2 = ModelFactory.NewStyle(
            //    ModelFactory.NewFillColor(255, 0, 0),
            //    ModelFactory.NewLineColor(0, 255, 0),
            //    ModelFactory.NewFont("Times Roman", (float)12.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
            //);

            //var node0 = ModelFactory.NewNode("Node 0 " + DateTime.Now.ToString(),
            //                            0, 0, 0, 50, 50, 50,
            //                            elementArray[0], null, null, style1,
            //                            new node[] { ModelFactory.NewNode("Sub Node " + DateTime.Now.ToString(),
            //                                            10, 10, 10, 25, 25, 25,
            //                                            elementArray[3])
            //                            }
            //            );
            //var node1 = ModelFactory.NewNode("Node 1 " + DateTime.Now.ToString(),
            //                            100, 100, 100, 50, 50, 50,
            //                            elementArray[1], null, null, style2,
            //                            null
            //            );

            //var bendpoint1 = ModelFactory.NewBendPoint(25, 25, 25);
            //var connection1 = ModelFactory.NewConnection("Connection 1 " + DateTime.Now.ToString(),
            //                    node0, node1, relationship1
            //                  );
            //connection1.bendpoint.Add(bendpoint1);

            //view view2;
            //var views = ModelFactory.NewViews(
            //                view2 = ModelFactory.NewView("View 2 " + DateTime.Now.ToString(), ModelConst.ViewType.Layered,
            //                    new node[] {
            //                        node0, node1
            //                    },
            //                    new connection[] { connection1 }
            //                )
            //            );
            //model2.views.Add(views);

            //tenant2.processinghistory.Add(
            //ModelFactory.NewProcessinghistory(
            //    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //        ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //        null, null,
            //        ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //        )
            //    )
            //)
            //);
            //tenant2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //tenant2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //tenant2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //model2.processinghistory.Add(
            //            ModelFactory.NewProcessinghistory(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //elementArray[0].processinghistory.Add(
            //ModelFactory.NewProcessinghistory(
            //    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //        ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //        null, null,
            //        ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //        )
            //    )
            //)
            //);
            //elementArray[0].usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //elementArray[0].performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //elementArray[0].management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //view2.processinghistory.Add(
            //            ModelFactory.NewProcessinghistory(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                folders fs0 = tTarget.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                ModelMigrator.MigrateModel(ctxTarget, tTarget, f0,
                                           mSource, PCOOperation.merge, PCOOperation.merge, true);
            }

            Console.WriteLine("Press enter to exist...");
            Console.ReadLine();
        }