public void Initialize()
        {
            this.edmModel = new EdmModel();

            this.defaultContainer = new EdmEntityContainer("TestModel", "DefaultContainer");
            this.edmModel.AddElement(this.defaultContainer);

            this.townType = new EdmEntityType("TestModel", "Town");
            this.edmModel.AddElement(townType);
            EdmStructuralProperty townIdProperty = townType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            townType.AddKeys(townIdProperty);
            townType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(/*isNullable*/false));
            townType.AddStructuralProperty("Size", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));

            this.cityType = new EdmEntityType("TestModel", "City", this.townType);
            cityType.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
            this.edmModel.AddElement(cityType);

            this.districtType = new EdmEntityType("TestModel", "District");
            EdmStructuralProperty districtIdProperty = districtType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            districtType.AddKeys(districtIdProperty);
            districtType.AddStructuralProperty("Zip", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            districtType.AddStructuralProperty("Thumbnail", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
            this.edmModel.AddElement(districtType);

            cityType.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo { Name = "Districts", Target = districtType, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo { Name = "City", Target = cityType, TargetMultiplicity = EdmMultiplicity.One });

            this.defaultContainer.AddEntitySet("Cities", cityType);
            this.defaultContainer.AddEntitySet("Districts", districtType);

            this.metropolisType = new EdmEntityType("TestModel", "Metropolis", this.cityType);
            this.metropolisType.AddStructuralProperty("MetropolisStream", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
            this.edmModel.AddElement(metropolisType);

            metropolisType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MetropolisNavigation", Target = districtType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            this.action = new EdmAction("TestModel", "Action", new EdmEntityTypeReference(this.cityType, true));
            this.action.AddParameter("Param", EdmCoreModel.Instance.GetInt32(false));
            this.edmModel.AddElement(action);
            this.actionImport = new EdmActionImport(this.defaultContainer, "Action", action);

            this.actionConflictingWithPropertyName = new EdmAction("TestModel", "Zip", new EdmEntityTypeReference(this.districtType, true));
            this.actionConflictingWithPropertyName.AddParameter("Param", EdmCoreModel.Instance.GetInt32(false));
            this.edmModel.AddElement(actionConflictingWithPropertyName);
            this.actionImportConflictingWithPropertyName = new EdmActionImport(this.defaultContainer, "Zip", actionConflictingWithPropertyName);

            this.openType = new EdmEntityType("TestModel", "OpenCity", this.cityType, false, true);
        }
Esempio n. 2
0
        public static IEdmModel ModelWithAllConceptsEdm()
        {
            var stringType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String);

            var model = new EdmModel();
            var addressType = new EdmComplexType("NS1", "Address");
            addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("City", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/30, /*isUnicode*/true));
            model.AddElement(addressType);

            var zipCodeType = new EdmComplexType("NS1", "ZipCode");
            zipCodeType.AddStructuralProperty("Main", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false));
            zipCodeType.AddStructuralProperty("Extended", new EdmStringTypeReference(stringType, /*isNullable*/true, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false));
            model.AddElement(zipCodeType);
            addressType.AddStructuralProperty("Zip", new EdmComplexTypeReference(zipCodeType, false));

            var foreignAddressType = new EdmComplexType("NS1", "ForeignAddress", addressType, false);
            foreignAddressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
            model.AddElement(foreignAddressType);

            var personType = new EdmEntityType("NS1", "Person", null, true, false);
            personType.AddKeys(personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false));
            model.AddElement(personType);

            var customerType = new EdmEntityType("NS1", "Customer", personType);
            customerType.AddStructuralProperty("IsVIP", EdmPrimitiveTypeKind.Boolean);
            customerType.AddProperty(new EdmStructuralProperty(customerType, "LastUpdated", EdmCoreModel.Instance.GetDateTimeOffset(false), null, EdmConcurrencyMode.Fixed));
            customerType.AddStructuralProperty("BillingAddress", new EdmComplexTypeReference(addressType, false));
            customerType.AddStructuralProperty("ShippingAddress", new EdmComplexTypeReference(addressType, false));
            model.AddElement(customerType);

            var orderType = new EdmEntityType("NS1", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false));
            var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
            model.AddElement(orderType);

            var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, };
            var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key() };
            customerType.AddBidirectionalNavigation(navProp1, navProp2);

            var container = new EdmEntityContainer("NS1", "MyContainer");
            container.AddEntitySet("PersonSet", personType);
            container.AddEntitySet("OrderSet", orderType);
            model.AddElement(container);

            var function = new EdmFunction("NS1", "Function1", EdmCoreModel.Instance.GetInt64(true));
            function.AddParameter("Param1", EdmCoreModel.Instance.GetInt32(true));
            container.AddFunctionImport(function);
            model.AddElement(function);

            return model;
        }
Esempio n. 3
0
        public static IEdmModel AssociationIndependentEdm()
        {
            var model = new EdmModel();
            var customerType = new EdmEntityType("NS1", "Customer");
            customerType.AddKeys(customerType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(customerType);

            var orderType = new EdmEntityType("NS1", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(orderType);

            var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many };
            var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One };
            customerType.AddBidirectionalNavigation(navProp1, navProp2);

            return model;
        }
Esempio n. 4
0
        public static IEdmModel MultipleNamespacesEdm()
        {
            var model = new EdmModel();
            var personType = new EdmEntityType("NS1", "Person");
            personType.AddKeys(personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(personType);

            var complexType1 = new EdmComplexType("NS3", "ComplexLevel1");
            model.AddElement(complexType1);
            var complexType2 = new EdmComplexType("NS2", "ComplexLevel2");
            model.AddElement(complexType2);
            var complexType3 = new EdmComplexType("NS2", "ComplexLevel3");
            model.AddElement(complexType3);

            complexType3.AddStructuralProperty("IntProperty", EdmPrimitiveTypeKind.Int32);
            complexType2.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType3, false));
            complexType1.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType2, false));
            personType.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType1, false));

            var customerType = new EdmEntityType("NS3", "Customer", personType);
            model.AddElement(customerType);

            var orderType = new EdmEntityType("NS2", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(orderType);

            var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32);
            var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, };
            var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key() };
            customerType.AddBidirectionalNavigation(navProp1, navProp2);

            return model;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a model, used model information at http://schema.org/Person as inspiration
        /// </summary>
        /// <returns></returns>
        public static IEdmModel BuildModel(string modelNamespace)
        {
            var edmModel = new EdmModel();
            var container = new EdmEntityContainer(modelNamespace, "Container");
            edmModel.AddElement(container);

            // Create types
            var addressType = new EdmComplexType(modelNamespace, "PostalAddress");
            addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
            var addressRefType = new EdmComplexTypeReference(addressType, true);

            var placeType = new EdmEntityType(modelNamespace, "Place");
            var placeTypeKeyProp = placeType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32);
            placeType.AddKeys(placeTypeKeyProp);
            placeType.AddStructuralProperty("MapUri", EdmPrimitiveTypeKind.String);
            placeType.AddStructuralProperty("TelephoneNumber", EdmPrimitiveTypeKind.String);
            placeType.AddStructuralProperty("Address", addressRefType);

            var personType = new EdmEntityType(modelNamespace, "Person");
            var personTypeKeyProp = personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32);
            personType.AddKeys(personTypeKeyProp);
            personType.AddStructuralProperty("FirstName", EdmPrimitiveTypeKind.String);
            personType.AddStructuralProperty("LastName", EdmPrimitiveTypeKind.String);
            personType.AddStructuralProperty("Address", addressRefType);

            var organizationType = new EdmEntityType(modelNamespace, "Organization");
            var organizationTypeKeyProp = organizationType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32);
            organizationType.AddKeys(organizationTypeKeyProp);
            organizationType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            organizationType.AddStructuralProperty("Address", addressRefType);

            var corporationType = new EdmEntityType(modelNamespace, "Corporation", organizationType);
            corporationType.AddStructuralProperty("TickerSymbol", EdmPrimitiveTypeKind.String);

            var localBusinessType = new EdmEntityType(modelNamespace, "LocalBusiness", organizationType);

            // Create associations
            personType.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() {Name = "Employers", Target = organizationType, TargetMultiplicity = EdmMultiplicity.Many}, 
                new EdmNavigationPropertyInfo() {Name = "Employees", Target = personType, TargetMultiplicity = EdmMultiplicity.Many});

            personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "CurrentPosition", Target = placeType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            personType.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Children", Target = personType, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Parent", Target = personType, TargetMultiplicity = EdmMultiplicity.One });

            localBusinessType.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "LocalBusinessBranches", Target = organizationType, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "MainOrganization", Target = localBusinessType, TargetMultiplicity = EdmMultiplicity.One });

            edmModel.AddElement(addressType);
            edmModel.AddElement(personType);
            edmModel.AddElement(organizationType);
            edmModel.AddElement(corporationType);
            edmModel.AddElement(localBusinessType);
            edmModel.AddElement(placeType);

            container.AddEntitySet("People", personType);
            container.AddEntitySet("Organizations", organizationType); 
            container.AddEntitySet("Places", organizationType);
            
            return edmModel;
        }
        public void TwoWayNavigationPropertyMultipleMappingInSingletonTest()
        {
            var model = new EdmModel();
            var t3 = new EdmEntityType("Bunk", "T3");
            var f31 = t3.AddStructuralProperty("F31", EdmCoreModel.Instance.GetString(false));
            t3.AddKeys(f31);
            model.AddElement(t3);

            var t1 = new EdmEntityType("Bunk", "T1");
            var f11 = t1.AddStructuralProperty("F11", EdmCoreModel.Instance.GetString(false));
            t1.AddKeys(f11);
            var p101 = t1.AddBidirectionalNavigation
                                    (
                                        new EdmNavigationPropertyInfo() { Name = "P101", Target = t3, TargetMultiplicity = EdmMultiplicity.One },
                                        new EdmNavigationPropertyInfo() { Name = "P301", TargetMultiplicity = EdmMultiplicity.One }
                                    );
            model.AddElement(t1);

            var c1 = new EdmEntityContainer("Bunk", "Gunk");
            var E1a = c1.AddEntitySet("E1a", t1);
            var E1b = c1.AddSingleton("E1b", t1);
            var E3 = c1.AddSingleton("E3", t3);
            E1a.AddNavigationTarget(p101, E3);
            E1b.AddNavigationTarget(p101, E3);
            E3.AddNavigationTarget(p101.Partner, E1a);
            model.AddElement(c1);

            var expectedErrors = new EdmLibTestErrors()
            {
                { "(Microsoft.OData.Edm.Library.EdmSingleton)", EdmErrorCode.NavigationMappingMustBeBidirectional },
            };
            IEnumerable<EdmError> edmErrors;
            model.Validate(out edmErrors);
            this.CompareErrors(edmErrors, expectedErrors);
        }
        public void ConstructibleModelODataTestModelDefaultModel()
        {
            EdmModel model = new EdmModel();

            EdmComplexType aliases = new EdmComplexType("DefaultNamespace", "Aliases");
            EdmStructuralProperty aliasesAlternativeNames = aliases.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false)));
            model.AddElement(aliases);

            EdmComplexType phone = new EdmComplexType("DefaultNamespace", "Phone");
            EdmStructuralProperty phoneNumber = phone.AddStructuralProperty("PhoneNumber", EdmCoreModel.Instance.GetString(false, 16, null, false));
            EdmStructuralProperty phoneExtension = phone.AddStructuralProperty("Extension", EdmCoreModel.Instance.GetString(false, 16, null, true));
            model.AddElement(phone);

            EdmComplexType contact = new EdmComplexType("DefaultNamespace", "ContactDetails");
            EdmStructuralProperty contactEmailBag = contact.AddStructuralProperty("EmailBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 32, null, false)));
            EdmStructuralProperty contactAlternativeNames = contact.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false)));
            EdmStructuralProperty contactAlias = contact.AddStructuralProperty("ContactAlias", new EdmComplexTypeReference(aliases, false));
            EdmStructuralProperty contactHomePhone = contact.AddStructuralProperty("HomePhone", new EdmComplexTypeReference(phone, false));
            EdmStructuralProperty contactWorkPhone = contact.AddStructuralProperty("WorkPhone", new EdmComplexTypeReference(phone, false));
            EdmStructuralProperty contactMobilePhoneBag = contact.AddStructuralProperty("MobilePhoneBag", EdmCoreModel.GetCollection(new EdmComplexTypeReference(phone, false)));
            model.AddElement(contact);

            EdmComplexType category = new EdmComplexType("DefaultNamespace", "ComplexToCategory");
            EdmStructuralProperty categoryTerm = category.AddStructuralProperty("Term", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty categoryScheme = category.AddStructuralProperty("Scheme", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty categoryLabel = category.AddStructuralProperty("Label", EdmCoreModel.Instance.GetString(false));
            model.AddElement(category);

            EdmComplexType dimensions = new EdmComplexType("DefaultNamespace", "Dimensions");
            EdmStructuralProperty dimensionsWidth = dimensions.AddStructuralProperty("Width", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            EdmStructuralProperty dimensionsHeight = dimensions.AddStructuralProperty("Height", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            EdmStructuralProperty dimensionsDepth = dimensions.AddStructuralProperty("Depth", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            model.AddElement(dimensions);

            EdmComplexType concurrency = new EdmComplexType("DefaultNamespace", "ConcurrencyInfo");
            EdmStructuralProperty concurrencyToken = concurrency.AddStructuralProperty("Token", EdmCoreModel.Instance.GetString(false, 20, null, false));
            EdmStructuralProperty concurrencyQueriedDateTime = concurrency.AddStructuralProperty("QueriedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(concurrency);

            EdmComplexType audit = new EdmComplexType("DefaultNamespace", "AuditInfo");
            EdmStructuralProperty auditModifiedDate = audit.AddStructuralProperty("ModifiedDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty auditModifiedBy = audit.AddStructuralProperty("ModifiedBy", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty auditConcurrency = audit.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false));
            model.AddElement(audit);

            EdmEntityType customer = new EdmEntityType("DefaultNamespace", "Customer");
            EdmStructuralProperty customerId = customer.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false));
            customer.AddKeys(customerId);
            EdmStructuralProperty customerName = customer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            EdmStructuralProperty customerPrimaryContact = customer.AddStructuralProperty("PrimaryContactInfo", new EdmComplexTypeReference(contact, false));
            EdmStructuralProperty customerBackupContact = customer.AddStructuralProperty("BackupContactInfo", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, false)));
            EdmStructuralProperty customerAuditing = customer.AddStructuralProperty("Auditing", new EdmComplexTypeReference(audit, false));
            EdmStructuralProperty customerThumbnail = customer.AddStructuralProperty("Thumbnail", EdmCoreModel.Instance.GetStream(false));
            EdmStructuralProperty customerVideo = customer.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(customer);

            EdmEntityType barcode = new EdmEntityType("DefaultNamespace", "Barcode");
            EdmStructuralProperty barcodeCode = barcode.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false));
            barcode.AddKeys(barcodeCode);
            EdmStructuralProperty barcodeProductId = barcode.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty barcodeText = barcode.AddStructuralProperty("Text", EdmCoreModel.Instance.GetString(false));
            model.AddElement(barcode);

            EdmEntityType incorrectScan = new EdmEntityType("DefaultNamespace", "IncorrectScan");
            EdmStructuralProperty incorrectScanId = incorrectScan.AddStructuralProperty("IncorrectScanId", EdmCoreModel.Instance.GetInt32(false));
            incorrectScan.AddKeys(incorrectScanId);
            EdmStructuralProperty incorrectScanExpectedCode = incorrectScan.AddStructuralProperty("ExpectedCode", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty incorrectScanActualCode = incorrectScan.AddStructuralProperty("ActualCode", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty incorrectScanDate = incorrectScan.AddStructuralProperty("ScanDate", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDateTimeOffset(false)));
            EdmStructuralProperty incorrectScanDetails = incorrectScan.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(incorrectScan);

            EdmEntityType barcodeDetail = new EdmEntityType("DefaultNamespace", "BarcodeDetail");
            EdmStructuralProperty barcodeDetailCode = barcodeDetail.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false));
            barcodeDetail.AddKeys(barcodeDetailCode);
            EdmStructuralProperty barcodeDetailRegisteredTo = barcodeDetail.AddStructuralProperty("RegisteredTo", EdmCoreModel.Instance.GetString(false));
            model.AddElement(barcodeDetail);

            EdmEntityType complaint = new EdmEntityType("DefaultNamespace", "Complaint");
            EdmStructuralProperty complaintId = complaint.AddStructuralProperty("ComplaintId", EdmCoreModel.Instance.GetInt32(false));
            complaint.AddKeys(complaintId);
            EdmStructuralProperty complaintCustomerId = complaint.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty complaintLogged = complaint.AddStructuralProperty("Logged", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty complaintDetails = complaint.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(complaint);

            EdmEntityType resolution = new EdmEntityType("DefaultNamespace", "Resolution");
            EdmStructuralProperty resolutionId = resolution.AddStructuralProperty("ResolutionId", EdmCoreModel.Instance.GetInt32(false));
            resolution.AddKeys(resolutionId);
            EdmStructuralProperty resolutionDetails = resolution.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(resolution);

            EdmEntityType login = new EdmEntityType("DefaultNamespace", "Login");
            EdmStructuralProperty loginUsername = login.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            login.AddKeys(loginUsername);
            EdmStructuralProperty loginCustomerId = login.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(login);

            EdmEntityType suspiciousActivity = new EdmEntityType("DefaultNamespace", "SuspiciousActivity");
            EdmStructuralProperty suspiciousActivityId = suspiciousActivity.AddStructuralProperty("SuspiciousActivityId", EdmCoreModel.Instance.GetInt32(false));
            suspiciousActivity.AddKeys(suspiciousActivityId);
            EdmStructuralProperty suspiciousActivityProperty = suspiciousActivity.AddStructuralProperty("Activity", EdmCoreModel.Instance.GetString(false));
            model.AddElement(suspiciousActivity);

            EdmEntityType smartCard = new EdmEntityType("DefaultNamespace", "SmartCard");
            EdmStructuralProperty smartCardUsername = smartCard.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            smartCard.AddKeys(smartCardUsername);
            EdmStructuralProperty smartCardSerial = smartCard.AddStructuralProperty("CardSerial", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty smartCardIssued = smartCard.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(smartCard);

            EdmEntityType rsaToken = new EdmEntityType("DefaultNamespace", "RSAToken");
            EdmStructuralProperty rsaTokenSerial = rsaToken.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false, 20, null, false));
            rsaToken.AddKeys(rsaTokenSerial);
            EdmStructuralProperty rsaTokenIssued = rsaToken.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(rsaToken);

            EdmEntityType passwordReset = new EdmEntityType("DefaultNamespace", "PasswordReset");
            EdmStructuralProperty passwordResetNo = passwordReset.AddStructuralProperty("ResetNo", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty passwordResetUsername = passwordReset.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            passwordReset.AddKeys(passwordResetNo);
            passwordReset.AddKeys(passwordResetUsername);
            EdmStructuralProperty passwordResetTempPassword = passwordReset.AddStructuralProperty("TempPassword", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty passwordResetEmailedTo = passwordReset.AddStructuralProperty("EmailedTo", EdmCoreModel.Instance.GetString(false));
            model.AddElement(passwordReset);

            EdmEntityType pageView = new EdmEntityType("DefaultNamespace", "PageView");
            EdmStructuralProperty pageViewId = pageView.AddStructuralProperty("PageViewId", EdmCoreModel.Instance.GetInt32(false));
            pageView.AddKeys(pageViewId);
            EdmStructuralProperty pageViewUsername = pageView.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty pageViewed = pageView.AddStructuralProperty("Viewed", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty pageViewPageUrl = pageView.AddStructuralProperty("PageUrl", EdmCoreModel.Instance.GetString(false, 500, null, false));
            model.AddElement(pageView);

            EdmEntityType productPageView = new EdmEntityType("DefaultNamespace", "ProductPageView", pageView);
            EdmStructuralProperty productPageViewId = productPageView.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(productPageView);

            EdmEntityType lastLogin = new EdmEntityType("DefaultNamespace", "LastLogin");
            EdmStructuralProperty lastLoginUsername = lastLogin.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            lastLogin.AddKeys(lastLoginUsername);
            EdmStructuralProperty lastLoginLoggedIn = lastLogin.AddStructuralProperty("LoggedIn", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty lastLoginLoggedOut = lastLogin.AddStructuralProperty("LoggedOut", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(lastLogin);

            EdmEntityType message = new EdmEntityType("DefaultNamespace", "Message");
            EdmStructuralProperty messageId = message.AddStructuralProperty("MessageId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty messageFromUsername = message.AddStructuralProperty("FromUsername", EdmCoreModel.Instance.GetString(false, 50, null, false));
            message.AddKeys(messageId);
            message.AddKeys(messageFromUsername);
            EdmStructuralProperty messageToUsername = message.AddStructuralProperty("ToUsername", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty messageSent = message.AddStructuralProperty("Sent", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty messageSubject = message.AddStructuralProperty("Subject", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty messageBody = message.AddStructuralProperty("Body", EdmCoreModel.Instance.GetString(true));
            EdmStructuralProperty messageIsRead = message.AddStructuralProperty("IsRead", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(message);

            EdmEntityType order = new EdmEntityType("DefaultNamespace", "Order");
            EdmStructuralProperty orderId = order.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            order.AddKeys(orderId);
            EdmStructuralProperty orderCustomerId = order.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty orderConcurrency = order.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false));
            model.AddElement(order);

            EdmEntityType orderNote = new EdmEntityType("DefaultNamespace", "OrderNote");
            EdmStructuralProperty orderNoteId = orderNote.AddStructuralProperty("NoteId", EdmCoreModel.Instance.GetInt32(false));
            orderNote.AddKeys(orderNoteId);
            EdmStructuralProperty orderNoteDescription = orderNote.AddStructuralProperty("Note", EdmCoreModel.Instance.GetString(false));
            model.AddElement(orderNote);

            EdmEntityType orderQualityCheck = new EdmEntityType("DefaultNamespace", "OrderQualityCheck");
            EdmStructuralProperty orderQualityCheckId = orderQualityCheck.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            orderQualityCheck.AddKeys(orderQualityCheckId);
            EdmStructuralProperty orderQualityCheckBy = orderQualityCheck.AddStructuralProperty("CheckedBy", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty orderQualityCheckDateTime = orderQualityCheck.AddStructuralProperty("CheckedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(orderQualityCheck);

            EdmEntityType orderLine = new EdmEntityType("DefaultNamespace", "OrderLine");
            EdmStructuralProperty orderLineOrderId = orderLine.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty orderLineProductId = orderLine.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            orderLine.AddKeys(orderLineOrderId);
            orderLine.AddKeys(orderLineProductId);
            EdmStructuralProperty orderLineQuantity = orderLine.AddStructuralProperty("Quantity", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty orderLineConcurrencyToken = orderLine.AddStructuralProperty("ConcurrencyToken", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed);
            EdmStructuralProperty orderLineStream = orderLine.AddStructuralProperty("OrderLineStream", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(orderLine);

            EdmEntityType backOrderLine = new EdmEntityType("DefaultNamespace", "BackOrderLine", orderLine);
            model.AddElement(backOrderLine);
            EdmEntityType backOrderLine2 = new EdmEntityType("DefaultNamespace", "BackOrderLine2", backOrderLine);
            model.AddElement(backOrderLine2);

            EdmEntityType product = new EdmEntityType("DefaultNamespace", "Product");
            EdmStructuralProperty productId = product.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            product.AddKeys(productId);
            EdmStructuralProperty productDescription = product.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 1000, true, true));
            EdmStructuralProperty productDimensions = product.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false));
            EdmStructuralProperty productBaseConcurrency = new EdmStructuralProperty( product, "BaseConcurrency", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed);
            product.AddProperty(productBaseConcurrency);
            EdmStructuralProperty productComplexConcurrency = product.AddStructuralProperty("ComplexConcurrency", new EdmComplexTypeReference(concurrency, false));
            EdmStructuralProperty productNestedComplexConcurrency = product.AddStructuralProperty("NestedComplexConcurrency", new EdmComplexTypeReference(audit, false));
            EdmStructuralProperty productPicture = product.AddStructuralProperty("Picture", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(product);

            EdmEntityType discontinuedProduct = new EdmEntityType("DefaultNamespace", "DiscontinuedProduct", product);
            EdmStructuralProperty discontinuedProductDate = discontinuedProduct.AddStructuralProperty("Discontinued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty discontinuedProductReplacementProductId = discontinuedProduct.AddStructuralProperty("ReplacementProductId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty discontinuedProductDiscontinuedPhone = discontinuedProduct.AddStructuralProperty("DiscontinuedPhone", new EdmComplexTypeReference(phone, false));
            model.AddElement(discontinuedProduct);

            EdmEntityType productDetail = new EdmEntityType("DefaultNamespace", "ProductDetail");
            EdmStructuralProperty productDetailProductId = productDetail.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            productDetail.AddKeys(productDetailProductId);
            EdmStructuralProperty productDetails = productDetail.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productDetail);

            EdmEntityType productReview = new EdmEntityType("DefaultNamespace", "ProductReview");
            EdmStructuralProperty productReviewProductId = productReview.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productReviewId = productReview.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false));
            productReview.AddKeys(productReviewProductId);
            productReview.AddKeys(productReviewId);
            EdmStructuralProperty productReviewDescription = productReview.AddStructuralProperty("Review", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productReview);

            EdmEntityType productPhoto = new EdmEntityType("DefaultNamespace", "ProductPhoto");
            EdmStructuralProperty productPhotoProductId = productPhoto.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productPhotoId = productPhoto.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(false));
            productPhoto.AddKeys(productPhotoProductId);
            productPhoto.AddKeys(productPhotoId);
            EdmStructuralProperty productPhotoBinary = productPhoto.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetBinary(false));
            model.AddElement(productPhoto);

            EdmEntityType productWebFeature = new EdmEntityType("DefaultNamespace", "ProductWebFeature");
            EdmStructuralProperty productWebFeatureId = productWebFeature.AddStructuralProperty("FeatureId", EdmCoreModel.Instance.GetInt32(false));
            productWebFeature.AddKeys(productWebFeatureId);
            EdmStructuralProperty productWebFeatureProductId = productWebFeature.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty productWebFeaturePhotoId = productWebFeature.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty productWebFeatureReviewId = productWebFeature.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productWebFeatureHeading = productWebFeature.AddStructuralProperty("Heading", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productWebFeature);

            EdmEntityType supplier = new EdmEntityType("DefaultNamespace", "Supplier");
            EdmStructuralProperty supplierId = supplier.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false));
            supplier.AddKeys(supplierId);
            EdmStructuralProperty supplierName = supplier.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(supplier);

            EdmEntityType supplierLogo = new EdmEntityType("DefaultNamespace", "SupplierLogo");
            EdmStructuralProperty supplierLogoSupplierId = supplierLogo.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false));
            supplierLogo.AddKeys(supplierLogoSupplierId);
            EdmStructuralProperty supplierLogoBinary = supplierLogo.AddStructuralProperty("Logo", EdmCoreModel.Instance.GetBinary(false, 500, false));
            model.AddElement(supplierLogo);

            EdmEntityType supplierInfo = new EdmEntityType("DefaultNamespace", "SupplierInfo");
            EdmStructuralProperty supplierInfoId = supplierInfo.AddStructuralProperty("SupplierInfoId", EdmCoreModel.Instance.GetInt32(false));
            supplierInfo.AddKeys(supplierInfoId);
            EdmStructuralProperty supplierInfoDescription = supplierInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(false));
            model.AddElement(supplierInfo);

            EdmEntityType customerInfo = new EdmEntityType("DefaultNamespace", "CustomerInfo");
            EdmStructuralProperty customerInfoId = customerInfo.AddStructuralProperty("CustomerInfoId", EdmCoreModel.Instance.GetInt32(false));
            customerInfo.AddKeys(customerInfoId);
            EdmStructuralProperty customerInfoDescription = customerInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(true));
            model.AddElement(customerInfo);

            EdmEntityType computer = new EdmEntityType("DefaultNamespace", "Computer");
            EdmStructuralProperty computerId = computer.AddStructuralProperty("ComputerId", EdmCoreModel.Instance.GetInt32(false));
            computer.AddKeys(computerId);
            EdmStructuralProperty computerName = computer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(computer);

            EdmEntityType computerDetail = new EdmEntityType("DefaultNamespace", "ComputerDetail");
            EdmStructuralProperty computerDetailId = computerDetail.AddStructuralProperty("ComputerDetailId", EdmCoreModel.Instance.GetInt32(false));
            computerDetail.AddKeys(computerDetailId);
            EdmStructuralProperty computerDetailManufacturer = computerDetail.AddStructuralProperty("Manufacturer", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailModel = computerDetail.AddStructuralProperty("Model", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailSerial = computerDetail.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailSpecificationsBag = computerDetail.AddStructuralProperty("SpecificationsBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false)));
            EdmStructuralProperty computerDetailPurchaseDate = computerDetail.AddStructuralProperty("PurchaseDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty computerDetailDimensions = computerDetail.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false));
            model.AddElement(computerDetail);

            EdmEntityType driver = new EdmEntityType("DefaultNamespace", "Driver");
            EdmStructuralProperty driverName = driver.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            driver.AddKeys(driverName);
            EdmStructuralProperty driverBirthDate = driver.AddStructuralProperty("BirthDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(driver);

            EdmEntityType license = new EdmEntityType("DefaultNamespace", "License");
            EdmStructuralProperty licenseName = license.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            license.AddKeys(licenseName);
            EdmStructuralProperty licenseNumber = license.AddStructuralProperty("LicenseNumber", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseClass = license.AddStructuralProperty("LicenseClass", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseRestrictions = license.AddStructuralProperty("Restrictions", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseExpiration = license.AddStructuralProperty("ExpirationDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(license);

            EdmEntityType mappedEntity = new EdmEntityType("DefaultNamespace", "MappedEntityType");
            EdmStructuralProperty mappedEntityId = mappedEntity.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            mappedEntity.AddKeys(mappedEntityId);
            EdmStructuralProperty mappedEntityHref = mappedEntity.AddStructuralProperty("Href", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityTitle = mappedEntity.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityHrefLang = mappedEntity.AddStructuralProperty("HrefLang", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityType = mappedEntity.AddStructuralProperty("Type", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityLength = mappedEntity.AddStructuralProperty("Length", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty mappedEntityBagOfPrimitiveToLinks = mappedEntity.AddStructuralProperty("BagOfPrimitiveToLinks", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false)));
            EdmStructuralProperty mappedEntityBagOfDecimals = mappedEntity.AddStructuralProperty("BagOfDecimals", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDecimal(false)));
            EdmStructuralProperty mappedEntityBagOfDoubles = mappedEntity.AddStructuralProperty("BagOfDoubles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDouble(false)));
            EdmStructuralProperty mappedEntityBagOfSingles = mappedEntity.AddStructuralProperty("BagOfSingles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetSingle(false)));
            EdmStructuralProperty mappedEntityBagOfBytes = mappedEntity.AddStructuralProperty("BagOfBytes", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetByte(false)));
            EdmStructuralProperty mappedEntityBagOfInt16s = mappedEntity.AddStructuralProperty("BagOfInt16s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt16(false)));
            EdmStructuralProperty mappedEntityBagOfInt32s = mappedEntity.AddStructuralProperty("BagOfInt32s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false)));
            EdmStructuralProperty mappedEntityBagOfInt64s = mappedEntity.AddStructuralProperty("BagOfInt64s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt64(false)));
            EdmStructuralProperty mappedEntityBagOfGuids = mappedEntity.AddStructuralProperty("BagOfGuids", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetGuid(false)));
            EdmStructuralProperty mappedEntityBagOfComplexToCategories = mappedEntity.AddStructuralProperty("BagOfComplexToCategories", EdmCoreModel.GetCollection(new EdmComplexTypeReference(category, false)));
            model.AddElement(mappedEntity);

            EdmEntityType car = new EdmEntityType("DefaultNamespace", "Car");
            EdmStructuralProperty carVin = car.AddStructuralProperty("VIN", EdmCoreModel.Instance.GetInt32(false));
            car.AddKeys(carVin);
            EdmStructuralProperty carDescription = car.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 100, null, true));
            EdmStructuralProperty carPhoto = car.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetStream(false));
            EdmStructuralProperty carVideo = car.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(car);

            EdmEntityType person = new EdmEntityType("DefaultNamespace", "Person");
            EdmStructuralProperty personId = person.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false));
            person.AddKeys(personId);
            EdmStructuralProperty personName = person.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(person);

            EdmEntityType employee = new EdmEntityType("DefaultNamespace", "Employee", person);
            EdmStructuralProperty employeeManagerId = employee.AddStructuralProperty("ManagersPersonId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty employeeSalary = employee.AddStructuralProperty("Salary", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty employeeTitle = employee.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false));
            model.AddElement(employee);

            EdmEntityType specialEmployee = new EdmEntityType("DefaultNamespace", "SpecialEmployee", employee);
            EdmStructuralProperty specialEmployeeCarsVIN = specialEmployee.AddStructuralProperty("CarsVIN", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty specialEmployeeBonus = specialEmployee.AddStructuralProperty("Bonus", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty specialEmployeeIsFullyVested = specialEmployee.AddStructuralProperty("IsFullyVested", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(specialEmployee);

            EdmEntityType personMetadata = new EdmEntityType("DefaultNamespace", "PersonMetadata");
            EdmStructuralProperty personMetadataId = personMetadata.AddStructuralProperty("PersonMetadataId", EdmCoreModel.Instance.GetInt32(false));
            personMetadata.AddKeys(personMetadataId);
            EdmStructuralProperty personMetadataPersonId = personMetadata.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty personMetadataPropertyName = personMetadata.AddStructuralProperty("PropertyName", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty personMetadataPropertyValue = personMetadata.AddStructuralProperty("PropertyValue", EdmCoreModel.Instance.GetString(false));
            model.AddElement(personMetadata);

            EdmNavigationProperty customerToOrders = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customer.Key() });

            EdmNavigationProperty customerToLogins = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Logins", Target = login, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new [] { loginCustomerId }, PrincipalProperties = customer.Key()});

            EdmNavigationProperty customerToHusband = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Husband", Target = customer, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Wife", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty customerToInfo = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Info", Target = customerInfo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty customerToComplaint = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Complaints", Target = complaint, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { complaintCustomerId }, PrincipalProperties = customer.Key() });

            EdmNavigationProperty barcodeToProduct = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeProductId }, PrincipalProperties = product.Key() },
                new EdmNavigationPropertyInfo() { Name = "Barcodes", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty barcodeToExpectedIncorrectScans = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "BadScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ExpectedBarcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { incorrectScanExpectedCode }, PrincipalProperties = barcode.Key() });

            EdmNavigationProperty barcodeToActualIncorrectScans = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "GoodScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ActualBarcode", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { incorrectScanActualCode }, PrincipalProperties = barcode.Key()});

            EdmNavigationProperty barcodeToBarcodeDetail = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Detail", Target = barcodeDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Barcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeDetailCode }, PrincipalProperties = barcode.Key()});

            EdmNavigationProperty complaintToResolution = complaint.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Resolution", Target = resolution, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Complaint", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty loginToLastLogin = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { lastLoginUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToSentMessages = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SentMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Sender", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageFromUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToReceivedMessages = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ReceivedMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Recipient", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageToUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToOrders = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty loginToSmartCard = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SmartCard", Target = smartCard, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { smartCardUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToRsaToken = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "RSAToken", Target = rsaToken, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty loginToPasswordReset = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PasswordResets", Target = passwordReset, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { passwordResetUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToPageView = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PageViews", Target = pageView, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { pageViewUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToSuspiciousActivity = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SuspiciousActivity", Target = suspiciousActivity, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty smartCardToLastLogin = smartCard.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "SmartCard", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty orderToOrderLines = order.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "OrderLines", Target = orderLine, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineOrderId }, PrincipalProperties = order.Key()});

            EdmNavigationProperty orderToOrderNotes = EdmNavigationProperty.CreateNavigationPropertyWithPartner(
                new EdmNavigationPropertyInfo() { Name = "Notes", Target = orderNote, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade },
                new EdmNavigationPropertyInfo() { Name = "Order", Target = order, TargetMultiplicity = EdmMultiplicity.One });
            order.AddProperty(orderToOrderNotes);
            orderNote.AddProperty(orderToOrderNotes.Partner);

            EdmNavigationProperty orderToOrderQualityCheck = order.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "OrderQualityCheck", Target = orderQualityCheck, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderQualityCheckId }, PrincipalProperties = order.Key()});

            EdmNavigationProperty orderLineToProduct = orderLine.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineProductId }, PrincipalProperties = product.Key()},
                new EdmNavigationPropertyInfo() { Name = "OrderLines", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty productToRelatedProducts = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "RelatedProducts", Target = product, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ProductToRelatedProducts", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty productToSuppliers = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Suppliers", Target = supplier, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Products", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty productToProductDetail = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Detail", Target = productDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productDetailProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productToProductReviews = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Reviews", Target = productReview, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productReviewProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productToProductPhotos = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Photos", Target = productPhoto, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPhotoProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productReviewToProductWebFeatures = productReview.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Review", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeatureReviewId, productWebFeatureProductId }, PrincipalProperties = productReview.Key()});

            EdmNavigationProperty productPhotoToProductWebFeatures = productPhoto.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Photo", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeaturePhotoId, productWebFeatureProductId }, PrincipalProperties = productPhoto.Key()});

            EdmNavigationProperty supplierToSupplierLogo = supplier.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Logo", Target = supplierLogo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Supplier", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { supplierLogoSupplierId }, PrincipalProperties = supplier.Key()});

            EdmNavigationProperty supplierToSupplierInfo = EdmNavigationProperty.CreateNavigationPropertyWithPartner(
                new EdmNavigationPropertyInfo() { Name = "SupplierInfo", Target = supplierInfo, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade },
                new EdmNavigationPropertyInfo() { Name = "Supplier", Target = supplier, TargetMultiplicity = EdmMultiplicity.One });
            supplier.AddProperty(supplierToSupplierInfo);
            supplierInfo.AddProperty(supplierToSupplierInfo.Partner);

            EdmNavigationProperty computerToComputerDetail = computer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ComputerDetail", Target = computerDetail, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "Computer", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty driverTolicense = driver.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "License", Target = license, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "Driver", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { licenseName }, PrincipalProperties = driver.Key()});

            EdmNavigationProperty personToPersonMetadata = person.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PersonMetadata", Target = personMetadata, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Person", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { personMetadataPersonId }, PrincipalProperties = person.Key()});

            EdmNavigationProperty employeeToManager = employee.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Manager", Target = employee, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { employeeManagerId }, PrincipalProperties = employee.Key()},
                new EdmNavigationPropertyInfo() { Name = "EmployeeToManager", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty specialEmployeeToCar = specialEmployee.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Car", Target = car, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { specialEmployeeCarsVIN }, PrincipalProperties = car.Key()},
                new EdmNavigationPropertyInfo() { Name = "SpecialEmployee", TargetMultiplicity = EdmMultiplicity.Many });

            EdmOperation getPrimitiveString = new EdmFunction("DefaultNamespace", "GetPrimitiveString", EdmCoreModel.Instance.GetString(true));
            model.AddElement(getPrimitiveString);
            EdmOperation getSpecificCustomer = new EdmFunction("DefaultNamespace", "GetSpecificCustomer", EdmCoreModel.GetCollection(new EdmEntityTypeReference(customer, true)));
            getSpecificCustomer.AddParameter("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(getSpecificCustomer);
            EdmOperation getCustomerCount = new EdmFunction("DefaultNamespace", "GetCustomerCount", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(getCustomerCount);
            EdmOperation getArgumentPlusOne = new EdmFunction("DefaultNamespace", "GetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true));
            getArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(getArgumentPlusOne);
            EdmOperation entityProjectionReturnsCollectionOfComplexTypes = new EdmFunction("DefaultNamespace", "EntityProjectionReturnsCollectionOfComplexTypes", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, true)));
            model.AddElement(entityProjectionReturnsCollectionOfComplexTypes);

            EdmOperation setArgumentPlusOne = new EdmAction("DefaultNamespace", "SetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true));
            setArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(setArgumentPlusOne);

            EdmEntityContainer container = new EdmEntityContainer("DefaultNamespace", "DefaultContainer");
            model.AddElement(container);

            EdmEntitySet carSet = container.AddEntitySet("Car", car);
            EdmEntitySet customerSet = container.AddEntitySet("Customer", customer);
            EdmEntitySet barcodeSet = container.AddEntitySet("Barcode", barcode);
            EdmEntitySet incorrectScanSet = container.AddEntitySet("IncorrectScan", incorrectScan);
            EdmEntitySet barcodeDetailSet = container.AddEntitySet("BarcodeDetail", barcodeDetail);
            EdmEntitySet complaintSet = container.AddEntitySet("Complaint", complaint);
            EdmEntitySet resolutionSet = container.AddEntitySet("Resolution", resolution);
            EdmEntitySet loginSet = container.AddEntitySet("Login", login);
            EdmEntitySet suspiciousActivitySet = container.AddEntitySet("SuspiciousActivity", suspiciousActivity);
            EdmEntitySet smartCardSet = container.AddEntitySet("SmartCard", smartCard);
            EdmEntitySet rsaTokenSet = container.AddEntitySet("RSAToken", rsaToken);
            EdmEntitySet passwordResetSet = container.AddEntitySet("PasswordReset", passwordReset);
            EdmEntitySet pageViewSet = container.AddEntitySet("PageView", pageView);
            EdmEntitySet lastLoginSet = container.AddEntitySet("LastLogin", lastLogin);
            EdmEntitySet messageSet = container.AddEntitySet("Message", message);
            EdmEntitySet orderSet = container.AddEntitySet("Order", order);
            EdmEntitySet orderNoteSet = container.AddEntitySet("OrderNote", orderNote);
            EdmEntitySet orderQualityCheckSet = container.AddEntitySet("OrderQualityCheck", orderQualityCheck);
            EdmEntitySet orderLineSet = container.AddEntitySet("OrderLine", orderLine);
            EdmEntitySet productSet = container.AddEntitySet("Product", product);
            EdmEntitySet productDetailSet = container.AddEntitySet("ProductDetail", productDetail);
            EdmEntitySet productReviewSet = container.AddEntitySet("ProductReview", productReview);
            EdmEntitySet productPhotoSet = container.AddEntitySet("ProductPhoto", productPhoto);
            EdmEntitySet productWebFeatureSet = container.AddEntitySet("ProductWebFeature", productWebFeature);
            EdmEntitySet supplierSet = container.AddEntitySet("Supplier", supplier);
            EdmEntitySet supplierLogoSet = container.AddEntitySet("SupplierLogo", supplierLogo);
            EdmEntitySet supplierInfoSet = container.AddEntitySet("SupplierInfo", supplierInfo);
            EdmEntitySet customerInfoSet = container.AddEntitySet("CustomerInfo", customerInfo);
            EdmEntitySet computerSet = container.AddEntitySet("Computer", computer);
            EdmEntitySet computerDetailSet = container.AddEntitySet("ComputerDetail", computerDetail);
            EdmEntitySet driverSet = container.AddEntitySet("Driver", driver);
            EdmEntitySet licenseSet = container.AddEntitySet("License", license);
            EdmEntitySet mappedEntitySet = container.AddEntitySet("MappedEntityType", mappedEntity);
            EdmEntitySet personSet = container.AddEntitySet("Person", person);
            EdmEntitySet personMetadataSet = container.AddEntitySet("PersonMetadata", personMetadata);

            complaintSet.AddNavigationTarget(customerToComplaint.Partner, customerSet);
            loginSet.AddNavigationTarget(loginToSentMessages, messageSet);
            loginSet.AddNavigationTarget(loginToReceivedMessages, messageSet);
            customerInfoSet.AddNavigationTarget(customerToInfo.Partner, customerSet);
            supplierSet.AddNavigationTarget(supplierToSupplierInfo, supplierInfoSet);
            loginSet.AddNavigationTarget(loginToOrders, orderSet);
            orderSet.AddNavigationTarget(orderToOrderNotes, orderNoteSet);
            orderSet.AddNavigationTarget(orderToOrderQualityCheck, orderQualityCheckSet);
            supplierSet.AddNavigationTarget(supplierToSupplierLogo, supplierLogoSet);
            customerSet.AddNavigationTarget(customerToOrders, orderSet);
            customerSet.AddNavigationTarget(customerToLogins, loginSet);
            loginSet.AddNavigationTarget(loginToLastLogin, lastLoginSet);
            lastLoginSet.AddNavigationTarget(smartCardToLastLogin.Partner, smartCardSet);
            orderSet.AddNavigationTarget(orderToOrderLines, orderLineSet);
            productSet.AddNavigationTarget(orderLineToProduct.Partner, orderLineSet);
            productSet.AddNavigationTarget(productToRelatedProducts, productSet);
            productSet.AddNavigationTarget(productToProductDetail, productDetailSet);
            productSet.AddNavigationTarget(productToProductReviews, productReviewSet);
            productSet.AddNavigationTarget(productToProductPhotos, productPhotoSet);
            productWebFeatureSet.AddNavigationTarget(productPhotoToProductWebFeatures.Partner, productPhotoSet);
            productWebFeatureSet.AddNavigationTarget(productReviewToProductWebFeatures.Partner, productReviewSet);
            complaintSet.AddNavigationTarget(complaintToResolution, resolutionSet);
            barcodeSet.AddNavigationTarget(barcodeToExpectedIncorrectScans, incorrectScanSet);
            customerSet.AddNavigationTarget(customerToHusband.Partner, customerSet);
            barcodeSet.AddNavigationTarget(barcodeToActualIncorrectScans, incorrectScanSet);
            productSet.AddNavigationTarget(barcodeToProduct.Partner, barcodeSet);
            barcodeSet.AddNavigationTarget(barcodeToBarcodeDetail, barcodeDetailSet);
            loginSet.AddNavigationTarget(loginToSuspiciousActivity, suspiciousActivitySet);
            loginSet.AddNavigationTarget(loginToRsaToken, rsaTokenSet);
            loginSet.AddNavigationTarget(loginToSmartCard, smartCardSet);
            loginSet.AddNavigationTarget(loginToPasswordReset, passwordResetSet);
            loginSet.AddNavigationTarget(loginToPageView, pageViewSet);
            computerSet.AddNavigationTarget(computerToComputerDetail, computerDetailSet);
            driverSet.AddNavigationTarget(driverTolicense, licenseSet);
            personSet.AddNavigationTarget(personToPersonMetadata, personMetadataSet);
            productSet.AddNavigationTarget(productToSuppliers, supplierSet);
            carSet.AddNavigationTarget(specialEmployeeToCar.Partner, personSet);
            personSet.AddNavigationTarget(employeeToManager, personSet);

            this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelDefaultModel, model);
        }
        public static IEdmModel ModelWithInvalidDependentProperties()
        {
            EdmModel model = new EdmModel();

            var entity1 = new EdmEntityType("Foo", "Bar");
            var id1 = new EdmStructuralProperty(entity1, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None);
            entity1.AddKeys(id1);

            var entity2 = new EdmEntityType("Foo", "Baz");
            var id2 = new EdmStructuralProperty(entity2, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None);
            entity2.AddKeys(id2);

            EdmNavigationProperty entity1Navigation = entity1.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ToBaz", Target = entity2, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { id2 }, PrincipalProperties = entity2.Key() },
                new EdmNavigationPropertyInfo() { Name = "ToBar", TargetMultiplicity = EdmMultiplicity.Many }); 

            model.AddElement(entity1);

            return model;
        }
        private void InitializeEdmModel()
        {
            this.edmModel = new EdmModel();

            EdmEntityContainer defaultContainer = new EdmEntityContainer("TestModel", "DefaultContainer");
            this.edmModel.AddElement(defaultContainer);

            EdmComplexType addressType = new EdmComplexType("TestModel", "Address");
            addressType.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(/*isNullable*/false));
            addressType.AddStructuralProperty("Zip", EdmCoreModel.Instance.GetString(/*isNullable*/false));

            this.cityType = new EdmEntityType("TestModel", "City");
            EdmStructuralProperty cityIdProperty = cityType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            cityType.AddKeys(cityIdProperty);
            cityType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(/*isNullable*/false));
            cityType.AddStructuralProperty("Size", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            cityType.AddStructuralProperty("Restaurants", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(/*isNullable*/false)));
            cityType.AddStructuralProperty("Address", new EdmComplexTypeReference(addressType, true));
            this.edmModel.AddElement(cityType);

            this.capitolCityType = new EdmEntityType("TestModel", "CapitolCity", cityType);
            capitolCityType.AddStructuralProperty("CapitolType", EdmCoreModel.Instance.GetString( /*isNullable*/false));
            this.edmModel.AddElement(capitolCityType);

            EdmEntityType districtType = new EdmEntityType("TestModel", "District");
            EdmStructuralProperty districtIdProperty = districtType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            districtType.AddKeys(districtIdProperty);
            districtType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(/*isNullable*/false));
            districtType.AddStructuralProperty("Zip", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
            this.edmModel.AddElement(districtType);

            cityType.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo { Name = "Districts", Target = districtType, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo { Name = "City", Target = cityType, TargetMultiplicity = EdmMultiplicity.One });

            cityType.NavigationProperties().Single(np => np.Name == "Districts");
            capitolCityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "CapitolDistrict", Target = districtType, TargetMultiplicity = EdmMultiplicity.One });
            capitolCityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "OutlyingDistricts", Target = districtType, TargetMultiplicity = EdmMultiplicity.Many });

            this.citySet = defaultContainer.AddEntitySet("Cities", cityType);
            defaultContainer.AddEntitySet("Districts", districtType);

            this.singletonCity = defaultContainer.AddSingleton("SingletonCity", cityType);
        }
Esempio n. 10
0
        public void DollarMetadata_Works_WithMultipleReferentialConstraints_ForUntypeModel()
        {
            // Arrange
            EdmModel model = new EdmModel();

            EdmEntityType customer = new EdmEntityType("DefaultNamespace", "Customer");
            customer.AddKeys(customer.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(isNullable: false)));
            customer.AddStructuralProperty("Name",
                EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isUnicode: null, isNullable: false));
            model.AddElement(customer);

            EdmEntityType order = new EdmEntityType("DefaultNamespace", "Order");
            order.AddKeys(order.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false)));
            EdmStructuralProperty orderCustomerId = order.AddStructuralProperty("CustomerForeignKey", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(order);

            customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo
                {
                    Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many
                },
                new EdmNavigationPropertyInfo
                {
                    Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                    DependentProperties = new[] { orderCustomerId },
                    PrincipalProperties = customer.Key()
                });

            const string expect =
                "        <Property Name=\"CustomerForeignKey\" Type=\"Edm.Int32\" />\r\n" +
                "        <NavigationProperty Name=\"Customer\" Type=\"DefaultNamespace.Customer\" Partner=\"Orders\">\r\n" +
                "          <ReferentialConstraint Property=\"CustomerForeignKey\" ReferencedProperty=\"CustomerId\" />\r\n" +
                "        </NavigationProperty>";

            HttpConfiguration config = new[] { typeof(MetadataController) }.GetHttpConfiguration();
            HttpServer server = new HttpServer(config);
            config.MapODataServiceRoute("odata", "odata", model);

            HttpClient client = new HttpClient(server);

            // Act
            HttpResponseMessage response = client.GetAsync("http://localhost/odata/$metadata").Result;

            // Assert
            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal("application/xml", response.Content.Headers.ContentType.MediaType);
            Assert.Contains(expect, response.Content.ReadAsStringAsync().Result);
        }
Esempio n. 11
0
        public static IEdmModel CreateODataServiceModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "InMemoryEntities");
            model.AddElement(defaultContainer);

            #region ComplexType
            var addressType = new EdmComplexType(ns, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "PostalCode", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(addressType);

            var homeAddressType = new EdmComplexType(ns, "HomeAddress", addressType, false);
            homeAddressType.AddProperty(new EdmStructuralProperty(homeAddressType, "FamilyName", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(homeAddressType);

            var companyAddressType = new EdmComplexType(ns, "CompanyAddress", addressType, false);
            companyAddressType.AddProperty(new EdmStructuralProperty(companyAddressType, "CompanyName", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(companyAddressType);

            var cityInformationType = new EdmComplexType(ns, "CityInformation");
            cityInformationType.AddProperty(new EdmStructuralProperty(cityInformationType, "CountryRegion", EdmCoreModel.Instance.GetString(false)));
            cityInformationType.AddProperty(new EdmStructuralProperty(cityInformationType, "IsCapital", EdmCoreModel.Instance.GetBoolean(false)));
            model.AddElement(cityInformationType);
            #endregion

            #region EnumType
            var accessLevelType = new EdmEnumType(ns, "AccessLevel", isFlags: true);
            accessLevelType.AddMember("None", new EdmIntegerConstant(0));
            accessLevelType.AddMember("Read", new EdmIntegerConstant(1));
            accessLevelType.AddMember("Write", new EdmIntegerConstant(2));
            accessLevelType.AddMember("Execute", new EdmIntegerConstant(4));
            accessLevelType.AddMember("ReadWrite", new EdmIntegerConstant(3));
            model.AddElement(accessLevelType);

            var colorType = new EdmEnumType(ns, "Color", isFlags: false);
            colorType.AddMember("Red", new EdmIntegerConstant(1));
            colorType.AddMember("Green", new EdmIntegerConstant(2));
            colorType.AddMember("Blue", new EdmIntegerConstant(4));
            model.AddElement(colorType);

            var companyCategory = new EdmEnumType(ns, "CompanyCategory", isFlags: false);
            companyCategory.AddMember("IT", new EdmIntegerConstant(0));
            companyCategory.AddMember("Communication", new EdmIntegerConstant(1));
            companyCategory.AddMember("Electronics", new EdmIntegerConstant(2));
            companyCategory.AddMember("Others", new EdmIntegerConstant(4));
            model.AddElement(companyCategory);
            #endregion

            #region Term
            model.AddElement(new EdmTerm(ns, "IsBoss", EdmCoreModel.Instance.GetBoolean(true), "Entity"));
            model.AddElement(new EdmTerm(ns, "AddressType", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(new EdmTerm(ns, "CityInfo", new EdmComplexTypeReference(cityInformationType, false)));
            model.AddElement(new EdmTerm(ns, "DisplayName", EdmCoreModel.Instance.GetString(true)));
            #endregion

            var personType = new EdmEntityType(ns, "Person");
            var personIdProperty = new EdmStructuralProperty(personType, "PersonID", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "MiddleName", EdmCoreModel.Instance.GetString(true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "HomeAddress", new EdmComplexTypeReference(addressType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Home", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Numbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "Emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true)))));

            model.AddElement(personType);
            var personSet = new EdmEntitySet(defaultContainer, "People", personType);
            defaultContainer.AddElement(personSet);
            var boss = new EdmSingleton(defaultContainer, "Boss", personType);
            defaultContainer.AddElement(boss);

            var customerType = new EdmEntityType(ns, "Customer", personType);
            customerType.AddProperty(new EdmStructuralProperty(customerType, "City", EdmCoreModel.Instance.GetString(false)));
            customerType.AddProperty(new EdmStructuralProperty(customerType, "Birthday", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            customerType.AddProperty(new EdmStructuralProperty(customerType, "TimeBetweenLastTwoOrders", EdmCoreModel.Instance.GetDuration(false)));
            model.AddElement(customerType);
            var customerSet = new EdmEntitySet(defaultContainer, "Customers", customerType);
            defaultContainer.AddElement(customerSet);

            EdmSingleton vipCustomer = new EdmSingleton(defaultContainer, "VipCustomer", customerType);
            defaultContainer.AddElement(vipCustomer);

            var employeeType = new EdmEntityType(ns, "Employee", personType);
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "DateHired", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "Office", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true)));
            model.AddElement(employeeType);
            var employeeSet = new EdmEntitySet(defaultContainer, "Employees", employeeType);
            defaultContainer.AddElement(employeeSet);

            var productType = new EdmEntityType(ns, "Product");
            var productIdProperty = new EdmStructuralProperty(productType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            productType.AddProperty(productIdProperty);
            productType.AddKeys(productIdProperty);
            productType.AddProperty(new EdmStructuralProperty(productType, "Name", EdmCoreModel.Instance.GetString(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "QuantityPerUnit", EdmCoreModel.Instance.GetString(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "UnitPrice", EdmCoreModel.Instance.GetSingle(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "QuantityInStock", EdmCoreModel.Instance.GetInt32(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "Discontinued", EdmCoreModel.Instance.GetBoolean(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "UserAccess", new EdmEnumTypeReference(accessLevelType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "SkinColor", new EdmEnumTypeReference(colorType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "CoverColors", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEnumTypeReference(colorType, false)))));
            model.AddElement(productType);
            var productSet = new EdmEntitySet(defaultContainer, "Products", productType);
            defaultContainer.AddElement(productSet);

            var productDetailType = new EdmEntityType(ns, "ProductDetail");
            var productDetailIdProperty1 = new EdmStructuralProperty(productDetailType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            var productDetailIdProperty2 = new EdmStructuralProperty(productDetailType, "ProductDetailID", EdmCoreModel.Instance.GetInt32(false));
            productDetailType.AddProperty(productDetailIdProperty1);
            productDetailType.AddKeys(productDetailIdProperty1);
            productDetailType.AddProperty(productDetailIdProperty2);
            productDetailType.AddKeys(productDetailIdProperty2);
            productDetailType.AddProperty(new EdmStructuralProperty(productDetailType, "ProductName", EdmCoreModel.Instance.GetString(false)));
            productDetailType.AddProperty(new EdmStructuralProperty(productDetailType, "Description", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(productDetailType);
            var productDetailSet = new EdmEntitySet(defaultContainer, "ProductDetails", productDetailType);
            defaultContainer.AddElement(productDetailSet);

            var productReviewType = new EdmEntityType(ns, "ProductReview");
            var productReviewIdProperty1 = new EdmStructuralProperty(productReviewType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            var productReviewIdProperty2 = new EdmStructuralProperty(productReviewType, "ProductDetailID", EdmCoreModel.Instance.GetInt32(false));
            var productReviewIdProperty3 = new EdmStructuralProperty(productReviewType, "ReviewTitle", EdmCoreModel.Instance.GetString(false));
            var productReviewIdProperty4 = new EdmStructuralProperty(productReviewType, "RevisionID", EdmCoreModel.Instance.GetInt32(false));
            productReviewType.AddProperty(productReviewIdProperty1);
            productReviewType.AddKeys(productReviewIdProperty1);
            productReviewType.AddProperty(productReviewIdProperty2);
            productReviewType.AddKeys(productReviewIdProperty2);
            productReviewType.AddProperty(productReviewIdProperty3);
            productReviewType.AddKeys(productReviewIdProperty3);
            productReviewType.AddProperty(productReviewIdProperty4);
            productReviewType.AddKeys(productReviewIdProperty4);
            productReviewType.AddProperty(new EdmStructuralProperty(productReviewType, "Comment", EdmCoreModel.Instance.GetString(false)));
            productReviewType.AddProperty(new EdmStructuralProperty(productReviewType, "Author", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(productReviewType);
            var productReviewSet = new EdmEntitySet(defaultContainer, "ProductReviews", productReviewType);
            defaultContainer.AddElement(productReviewSet);

            var abstractType = new EdmEntityType(ns, "AbstractEntity", null, true, false);
            model.AddElement(abstractType);

            var orderType = new EdmEntityType(ns, "Order", abstractType);
            var orderIdProperty = new EdmStructuralProperty(orderType, "OrderID", EdmCoreModel.Instance.GetInt32(false));
            orderType.AddProperty(orderIdProperty);
            orderType.AddKeys(orderIdProperty);
            orderType.AddProperty(new EdmStructuralProperty(orderType, "OrderDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShelfLife", EdmCoreModel.Instance.GetDuration(true)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "OrderShelfLifes", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDuration(true)))));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShipDate", EdmCoreModel.Instance.GetDate(false)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShipTime", EdmCoreModel.Instance.GetTimeOfDay(false)));

            model.AddElement(orderType);
            var orderSet = new EdmEntitySet(defaultContainer, "Orders", orderType);
            defaultContainer.AddElement(orderSet);

            var orderDetailType = new EdmEntityType(ns, "OrderDetail", abstractType);
            var orderId = new EdmStructuralProperty(orderDetailType, "OrderID", EdmCoreModel.Instance.GetInt32(false));
            orderDetailType.AddProperty(orderId);
            orderDetailType.AddKeys(orderId);
            var productId = new EdmStructuralProperty(orderDetailType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            orderDetailType.AddProperty(productId);
            orderDetailType.AddKeys(productId);
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "OrderPlaced", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "Quantity", EdmCoreModel.Instance.GetInt32(false)));
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "UnitPrice", EdmCoreModel.Instance.GetSingle(false)));

            model.AddElement(orderDetailType);
            var orderDetailSet = new EdmEntitySet(defaultContainer, "OrderDetails", orderDetailType);
            defaultContainer.AddElement(orderDetailSet);

            var parentNavigation = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Parent",
                Target = personType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var productOrderedNavigation = orderDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "ProductOrdered",
                Target = productType,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            var associatedOrderNavigation = orderDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "AssociatedOrder",
                Target = orderType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var loggedInEmployeeNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "LoggedInEmployee",
                Target = employeeType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var customerForOrderNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "CustomerForOrder",
                Target = customerType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var orderDetailsNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "OrderDetails",
                Target = orderDetailType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            var ordersNavigation = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Orders",
                Target = orderType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            var productProductDetailNavigation = productType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Details",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = productDetailType,
                DependentProperties = new List<IEdmStructuralProperty>()
                    {
                        productIdProperty
                    },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        productDetailIdProperty1
                    }
            });
            var productDetailProductNavigation = productDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "RelatedProduct",
                Target = productType,
                TargetMultiplicity = EdmMultiplicity.ZeroOrOne
            });
            var productDetailProductReviewNavigation = productDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Reviews",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = productReviewType,
                DependentProperties = new List<IEdmStructuralProperty>()
                    {
                        productDetailIdProperty1, 
                        productDetailIdProperty2,
                    },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        productReviewIdProperty1, 
                        productReviewIdProperty2
                    }
            });

            model.SetCoreChangeTrackingAnnotation(orderSet, new EdmStructuralProperty[] { orderIdProperty }, new EdmNavigationProperty[] { orderDetailsNavigation });

            ((EdmEntitySet)personSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)orderDetailSet).AddNavigationTarget(associatedOrderNavigation, orderSet);
            ((EdmEntitySet)orderDetailSet).AddNavigationTarget(productOrderedNavigation, productSet);
            ((EdmEntitySet)customerSet).AddNavigationTarget(ordersNavigation, orderSet);
            ((EdmEntitySet)customerSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)employeeSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(loggedInEmployeeNavigation, employeeSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(customerForOrderNavigation, customerSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(orderDetailsNavigation, orderDetailSet);
            ((EdmEntitySet)productSet).AddNavigationTarget(productProductDetailNavigation, productDetailSet);
            ((EdmEntitySet)productDetailSet).AddNavigationTarget(productDetailProductNavigation, productSet);
            ((EdmEntitySet)productDetailSet).AddNavigationTarget(productDetailProductReviewNavigation, productReviewSet);

            #region Singleton

            var departmentType = new EdmEntityType(ns, "Department", null);
            var departmentId = new EdmStructuralProperty(departmentType, "DepartmentID", EdmCoreModel.Instance.GetInt32(false));
            departmentType.AddProperty(departmentId);
            departmentType.AddKeys(departmentId);
            departmentType.AddProperty(new EdmStructuralProperty(departmentType, "Name", EdmCoreModel.Instance.GetString(false)));
            departmentType.AddProperty(new EdmStructuralProperty(departmentType, "DepartmentNO", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(departmentType);
            EdmEntitySet departments = new EdmEntitySet(defaultContainer, "Departments", departmentType);
            defaultContainer.AddElement(departments);

            var companyType = new EdmEntityType(ns, "Company", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ true);
            var companyId = new EdmStructuralProperty(companyType, "CompanyID", EdmCoreModel.Instance.GetInt32(false));
            companyType.AddProperty(companyId);
            companyType.AddKeys(companyId);
            companyType.AddProperty(new EdmStructuralProperty(companyType, "CompanyCategory", new EdmEnumTypeReference(companyCategory, true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Revenue", EdmCoreModel.Instance.GetInt64(false)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Address", new EdmComplexTypeReference(addressType, true)));

            model.AddElement(companyType);
            EdmSingleton company = new EdmSingleton(defaultContainer, "Company", companyType);
            defaultContainer.AddElement(company);

            var publicCompanyType = new EdmEntityType(ns, "PublicCompany", /*baseType*/ companyType, /*isAbstract*/ false, /*isOpen*/ true);
            publicCompanyType.AddProperty(new EdmStructuralProperty(publicCompanyType, "StockExchange", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(publicCompanyType);
            EdmSingleton publicCompany = new EdmSingleton(defaultContainer, "PublicCompany", companyType);
            defaultContainer.AddElement(publicCompany);

            var assetType = new EdmEntityType(ns, "Asset", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var assetId = new EdmStructuralProperty(assetType, "AssetID", EdmCoreModel.Instance.GetInt32(false));
            assetType.AddProperty(assetId);
            assetType.AddKeys(assetId);
            assetType.AddProperty(new EdmStructuralProperty(assetType, "Name", EdmCoreModel.Instance.GetString(true)));
            assetType.AddProperty(new EdmStructuralProperty(assetType, "Number", EdmCoreModel.Instance.GetInt32(false)));
            model.AddElement(assetType);

            var clubType = new EdmEntityType(ns, "Club", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var clubId = new EdmStructuralProperty(clubType, "ClubID", EdmCoreModel.Instance.GetInt32(false));
            clubType.AddProperty(clubId);
            clubType.AddKeys(clubId);
            clubType.AddProperty(new EdmStructuralProperty(clubType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(clubType);

            var labourUnionType = new EdmEntityType(ns, "LabourUnion", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var labourUnionId = new EdmStructuralProperty(labourUnionType, "LabourUnionID", EdmCoreModel.Instance.GetInt32(false));
            labourUnionType.AddProperty(labourUnionId);
            labourUnionType.AddKeys(labourUnionId);
            labourUnionType.AddProperty(new EdmStructuralProperty(labourUnionType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(labourUnionType);
            EdmSingleton labourUnion = new EdmSingleton(defaultContainer, "LabourUnion", labourUnionType);
            defaultContainer.AddElement(labourUnion);

            var companyEmployeeNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Employees",
                Target = employeeType,
                TargetMultiplicity = EdmMultiplicity.Many
            }, new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyCustomerNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "VipCustomer",
                Target = customerType,
                TargetMultiplicity = EdmMultiplicity.One
            }, new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyDepartmentsNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Departments",
                Target = departmentType,
                TargetMultiplicity = EdmMultiplicity.Many
            },
            new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyCoreDepartmentNavigation = companyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "CoreDepartment",
                Target = departmentType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var publicCompanyAssetNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Assets",
                Target = assetType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var publicCompanyClubNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Club",
                Target = clubType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = true
            });

            var publicCompanyLabourUnionNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "LabourUnion",
                Target = labourUnionType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            //vipCustomer->orders
            ((EdmSingleton)vipCustomer).AddNavigationTarget(ordersNavigation, orderSet);
            //vipCustomer->people
            ((EdmSingleton)vipCustomer).AddNavigationTarget(parentNavigation, personSet);
            ((EdmSingleton)boss).AddNavigationTarget(parentNavigation, personSet);
            //employeeSet<->company
            ((EdmSingleton)company).AddNavigationTarget(companyEmployeeNavigation, employeeSet);
            ((EdmEntitySet)employeeSet).AddNavigationTarget(companyEmployeeNavigation.Partner, company);
            //company<->vipcustomer
            ((EdmSingleton)company).AddNavigationTarget(companyCustomerNavigation, vipCustomer);
            ((EdmSingleton)vipCustomer).AddNavigationTarget(companyCustomerNavigation.Partner, company);
            //company<->departments
            ((EdmSingleton)company).AddNavigationTarget(companyDepartmentsNavigation, departments);
            ((EdmEntitySet)departments).AddNavigationTarget(companyDepartmentsNavigation.Partner, company);
            //company<-> Single department
            ((EdmSingleton)company).AddNavigationTarget(companyCoreDepartmentNavigation, departments);
            //publicCompany<-> Singleton
            ((EdmSingleton)publicCompany).AddNavigationTarget(publicCompanyLabourUnionNavigation, labourUnion);

            #region Action/Function
            //Bound Action : bound to Entity, return EnumType
            var productAddAccessRightAction = new EdmAction(ns, "AddAccessRight", new EdmEnumTypeReference(accessLevelType, true), true, null);
            productAddAccessRightAction.AddParameter("product", new EdmEntityTypeReference(productType, false));
            productAddAccessRightAction.AddParameter("accessRight", new EdmEnumTypeReference(accessLevelType, true));
            model.AddElement(productAddAccessRightAction);

            //Bound Action : Bound to Singleton, Primitive Parameter return Primitive Type
            EdmAction increaseRevenue = new EdmAction(ns, "IncreaseRevenue", EdmCoreModel.Instance.GetInt64(false), /*isBound*/true, /*entitySetPathExpression*/null);
            increaseRevenue.AddParameter(new EdmOperationParameter(increaseRevenue, "p", new EdmEntityTypeReference(companyType, false)));
            increaseRevenue.AddParameter(new EdmOperationParameter(increaseRevenue, "IncreaseValue", EdmCoreModel.Instance.GetInt64(true)));
            model.AddElement(increaseRevenue);

            //Bound Action : Bound to Entity, Collection Of ComplexType Parameter, Return Entity
            var resetAddressAction = new EdmAction(ns, "ResetAddress", new EdmEntityTypeReference(personType, false), true, new EdmPathExpression("person"));
            resetAddressAction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            resetAddressAction.AddParameter("addresses", new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(addressType, true))));
            resetAddressAction.AddParameter("index", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(resetAddressAction);

            //Bound Action : Bound to Entity, EntityType Parameter, Return Entity
            var placeOrderAction = new EdmAction(ns, "PlaceOrder", new EdmEntityTypeReference(orderType, false), true, new EdmPathExpression("customer/Orders"));
            placeOrderAction.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            placeOrderAction.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(placeOrderAction);

            //Bound Action : Bound to Entity, Collection Of EntityType Parameter, Return Collection of Entity
            var placeOrdersAction = new EdmAction(ns, "PlaceOrders", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(orderType, false))), true, new EdmPathExpression("customer/Orders"));
            placeOrdersAction.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            placeOrdersAction.AddParameter("orders", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(orderType, false))));
            model.AddElement(placeOrdersAction);

            //Bound Action : Bound to collection of EntitySet, Return Collection of Entity
            var discountSeveralProductAction = new EdmAction(ns, "Discount",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))), true, new EdmPathExpression("products"));
            discountSeveralProductAction.AddParameter("products", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))));
            discountSeveralProductAction.AddParameter("percentage", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(discountSeveralProductAction);

            //Bound Action : Bound to Entity, return void
            var changeLabourUnionNameAction = new EdmAction(ns, "ChangeLabourUnionName", null, true, null);
            changeLabourUnionNameAction.AddParameter("labourUnion", new EdmEntityTypeReference(labourUnionType, false));
            changeLabourUnionNameAction.AddParameter("name", EdmCoreModel.Instance.GetString(true));
            model.AddElement(changeLabourUnionNameAction);

            //Bound Action : Bound to Entity, return order take Date/TimeOfDay as Parameter
            var changeShipTimeAndDate = new EdmAction(ns, "ChangeShipTimeAndDate", new EdmEntityTypeReference(orderType, false), true, new EdmPathExpression("order"));
            changeShipTimeAndDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            changeShipTimeAndDate.AddParameter("date", EdmCoreModel.Instance.GetDate(false));
            changeShipTimeAndDate.AddParameter("time", EdmCoreModel.Instance.GetTimeOfDay(false));
            model.AddElement(changeShipTimeAndDate);

            //UnBound Action : Primitive parameter, Return void
            var discountAction = new EdmAction(ns, "Discount", null, false, null);
            discountAction.AddParameter("percentage", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(discountAction);
            defaultContainer.AddActionImport(discountAction);

            //UnBound Action : Collection of Primitive parameter, Return Collection of Primitive
            var resetBossEmailAction = new EdmAction(ns, "ResetBossEmail", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))), false, null);
            resetBossEmailAction.AddParameter("emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))));
            model.AddElement(resetBossEmailAction);
            defaultContainer.AddActionImport(resetBossEmailAction);

            //UnBound Action : ComplexType parameter, Return ComplexType
            var resetBossAddressAction = new EdmAction(ns, "ResetBossAddress", new EdmComplexTypeReference(addressType, false), false, null);
            resetBossAddressAction.AddParameter("address", new EdmComplexTypeReference(addressType, false));
            model.AddElement(resetBossAddressAction);
            defaultContainer.AddActionImport(resetBossAddressAction);

            //UnBound Action: ResetDataSource
            var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
            model.AddElement(resetDataSourceAction);
            defaultContainer.AddActionImport(resetDataSourceAction);

            //Bound Function : Bound to Singleton, Return PrimitiveType
            EdmFunction getCompanyEmployeeCount = new EdmFunction(ns, "GetEmployeesCount", EdmCoreModel.Instance.GetInt32(false), /*isBound*/true, /*entitySetPathExpression*/null, /*isComposable*/false);
            getCompanyEmployeeCount.AddParameter(new EdmOperationParameter(getCompanyEmployeeCount, "p", new EdmEntityTypeReference(companyType, false)));
            model.AddElement(getCompanyEmployeeCount);

            //Bound Function : Bound to Entity, Return CollectionOfEntity
            var getProductDetailsFunction = new EdmFunction(ns, "GetProductDetails",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productDetailType, false))),
                true, new EdmPathExpression("product/Details"), true);
            getProductDetailsFunction.AddParameter("product", new EdmEntityTypeReference(productType, false));
            getProductDetailsFunction.AddParameter("count", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(getProductDetailsFunction);

            //Bound Function : Bound to Entity, Return Entity
            var getRelatedProductFunction = new EdmFunction(ns, "GetRelatedProduct",
                new EdmEntityTypeReference(productType, false),
                true, new EdmPathExpression("productDetail/RelatedProduct"), true);
            getRelatedProductFunction.AddParameter("productDetail", new EdmEntityTypeReference(productDetailType, false));
            model.AddElement(getRelatedProductFunction);

            //Bound Function : Bound to Entity, Return Collection of Abstract Entity
            var getOrderAndOrderDetails = new EdmFunction(ns, "getOrderAndOrderDetails",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(abstractType, false))),
                true, new EdmPathExpression("customer/Orders"), true);
            getOrderAndOrderDetails.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            model.AddElement(getOrderAndOrderDetails);

            //Bound Function : Bound to CollectionOfEntity, Return Entity
            var getSeniorEmployees = new EdmFunction(ns, "GetSeniorEmployees",
                new EdmEntityTypeReference(employeeType, true),
                true, new EdmPathExpression("employees"), true);
            getSeniorEmployees.AddParameter("employees", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(employeeType, false))));
            model.AddElement(getSeniorEmployees);

            //Bound Function : Bound to Order, Return Edm.Date
            var getOrderShipDate = new EdmFunction(ns, "GetShipDate", EdmCoreModel.Instance.GetDate(false), true, null, false);
            getOrderShipDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(getOrderShipDate);

            //Bound Function : Bound to Order, Return Edm.TimeOfDay
            var getOrderShipTime = new EdmFunction(ns, "GetShipTime", EdmCoreModel.Instance.GetTimeOfDay(false), true, null, false);
            getOrderShipTime.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(getOrderShipTime);

            //Bound Function : Bound to Order, Parameter: Edm.TimeOfDay, Return Edm.Boolean
            var checkOrderShipTime = new EdmFunction(ns, "CheckShipTime", EdmCoreModel.Instance.GetBoolean(false), true, null, false);
            checkOrderShipTime.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            checkOrderShipTime.AddParameter("time", EdmCoreModel.Instance.GetTimeOfDay(false));
            model.AddElement(checkOrderShipTime);

            //Bound Function : Bound to Order, Parameter: Edm.Date, Return Edm.Boolean
            var checkOrderShipDate = new EdmFunction(ns, "CheckShipDate", EdmCoreModel.Instance.GetBoolean(false), true, null, false);
            checkOrderShipDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            checkOrderShipDate.AddParameter("date", EdmCoreModel.Instance.GetDate(false));
            model.AddElement(checkOrderShipDate);

            //UnBound Function : Return EnumType
            var defaultColorFunction = new EdmFunction(ns, "GetDefaultColor", new EdmEnumTypeReference(colorType, true), false, null, true);
            model.AddElement(defaultColorFunction);
            defaultContainer.AddFunctionImport("GetDefaultColor", defaultColorFunction, null, true);

            //UnBound Function : Complex Parameter, Return Entity
            var getPersonFunction = new EdmFunction(ns, "GetPerson",
                new EdmEntityTypeReference(personType, false),
                false, null, true);
            getPersonFunction.AddParameter("address", new EdmComplexTypeReference(addressType, false));
            model.AddElement(getPersonFunction);
            defaultContainer.AddFunctionImport("GetPerson", getPersonFunction, new EdmEntitySetReferenceExpression(personSet), true);

            //UnBound Function : Primtive Parameter, Return Entity
            var getPersonFunction2 = new EdmFunction(ns, "GetPerson2",
                new EdmEntityTypeReference(personType, false),
                false, null, true);
            getPersonFunction2.AddParameter("city", EdmCoreModel.Instance.GetString(false));
            model.AddElement(getPersonFunction2);
            defaultContainer.AddFunctionImport("GetPerson2", getPersonFunction2, new EdmEntitySetReferenceExpression(personSet), true);

            //UnBound Function : Return CollectionOfEntity
            var getAllProductsFunction = new EdmFunction(ns, "GetAllProducts",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))),
                false, null, true);
            model.AddElement(getAllProductsFunction);
            defaultContainer.AddFunctionImport("GetAllProducts", getAllProductsFunction, new EdmEntitySetReferenceExpression(productSet), true);

            //UnBound Function : Multi ParameterS Return Collection Of ComplexType
            var getBossEmailsFunction = new EdmFunction(ns, "GetBossEmails",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))),
                false, null, false);
            getBossEmailsFunction.AddParameter("start", EdmCoreModel.Instance.GetInt32(false));
            getBossEmailsFunction.AddParameter("count", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(getBossEmailsFunction);
            defaultContainer.AddFunctionImport(getBossEmailsFunction.Name, getBossEmailsFunction, null, true);

            var getProductsByAccessLevelFunction = new EdmFunction(ns, "GetProductsByAccessLevel",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))),
                false, null, false);
            getProductsByAccessLevelFunction.AddParameter("accessLevel", new EdmEnumTypeReference(accessLevelType, false));
            model.AddElement(getProductsByAccessLevelFunction);
            defaultContainer.AddFunctionImport(getProductsByAccessLevelFunction.Name, getProductsByAccessLevelFunction, null, true);

            #endregion

            #endregion

            #region For containment

            var accountInfoType = new EdmComplexType(ns, "AccountInfo", null, false, true);
            accountInfoType.AddProperty(new EdmStructuralProperty(accountInfoType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            accountInfoType.AddProperty(new EdmStructuralProperty(accountInfoType, "LastName", EdmCoreModel.Instance.GetString(false)));

            var accountType = new EdmEntityType(ns, "Account");
            var accountIdProperty = new EdmStructuralProperty(accountType, "AccountID", EdmCoreModel.Instance.GetInt32(false));
            accountType.AddProperty(accountIdProperty);
            accountType.AddKeys(accountIdProperty);
            accountType.AddProperty(new EdmStructuralProperty(accountType, "CountryRegion", EdmCoreModel.Instance.GetString(false)));
            accountType.AddProperty(new EdmStructuralProperty(accountType, "AccountInfo", new EdmComplexTypeReference(accountInfoType, true)));

            var giftCardType = new EdmEntityType(ns, "GiftCard");
            var giftCardIdProperty = new EdmStructuralProperty(giftCardType, "GiftCardID", EdmCoreModel.Instance.GetInt32(false));
            giftCardType.AddProperty(giftCardIdProperty);
            giftCardType.AddKeys(giftCardIdProperty);
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "GiftCardNO", EdmCoreModel.Instance.GetString(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "Amount", EdmCoreModel.Instance.GetDouble(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "ExperationDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "OwnerName", EdmCoreModel.Instance.GetString(true)));


            var paymentInstrumentType = new EdmEntityType(ns, "PaymentInstrument");
            var paymentInstrumentIdProperty = new EdmStructuralProperty(paymentInstrumentType, "PaymentInstrumentID", EdmCoreModel.Instance.GetInt32(false));
            paymentInstrumentType.AddProperty(paymentInstrumentIdProperty);
            paymentInstrumentType.AddKeys(paymentInstrumentIdProperty);
            paymentInstrumentType.AddProperty(new EdmStructuralProperty(paymentInstrumentType, "FriendlyName", EdmCoreModel.Instance.GetString(false)));
            paymentInstrumentType.AddProperty(new EdmStructuralProperty(paymentInstrumentType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var creditCardType = new EdmEntityType(ns, "CreditCardPI", paymentInstrumentType);
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "CardNumber", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "CVV", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "HolderName", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "Balance", EdmCoreModel.Instance.GetDouble(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "ExperationDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var storedPIType = new EdmEntityType(ns, "StoredPI");
            var storedPIIdProperty = new EdmStructuralProperty(storedPIType, "StoredPIID", EdmCoreModel.Instance.GetInt32(false));
            storedPIType.AddProperty(storedPIIdProperty);
            storedPIType.AddKeys(storedPIIdProperty);
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "PIName", EdmCoreModel.Instance.GetString(false)));
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "PIType", EdmCoreModel.Instance.GetString(false)));
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var statementType = new EdmEntityType(ns, "Statement");
            var statementIdProperty = new EdmStructuralProperty(statementType, "StatementID", EdmCoreModel.Instance.GetInt32(false));
            statementType.AddProperty(statementIdProperty);
            statementType.AddKeys(statementIdProperty);
            statementType.AddProperty(new EdmStructuralProperty(statementType, "TransactionType", EdmCoreModel.Instance.GetString(false)));
            statementType.AddProperty(new EdmStructuralProperty(statementType, "TransactionDescription", EdmCoreModel.Instance.GetString(false)));
            statementType.AddProperty(new EdmStructuralProperty(statementType, "Amount", EdmCoreModel.Instance.GetDouble(false)));

            var creditRecordType = new EdmEntityType(ns, "CreditRecord");
            var creditRecordIdProperty = new EdmStructuralProperty(creditRecordType, "CreditRecordID", EdmCoreModel.Instance.GetInt32(false));
            creditRecordType.AddProperty(creditRecordIdProperty);
            creditRecordType.AddKeys(creditRecordIdProperty);
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "IsGood", EdmCoreModel.Instance.GetBoolean(false)));
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "Reason", EdmCoreModel.Instance.GetString(false)));
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var subscriptionType = new EdmEntityType(ns, "Subscription");
            var subscriptionIdProperty = new EdmStructuralProperty(subscriptionType, "SubscriptionID", EdmCoreModel.Instance.GetInt32(false));
            subscriptionType.AddProperty(subscriptionIdProperty);
            subscriptionType.AddKeys(subscriptionIdProperty);
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "TemplateGuid", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "Title", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "Category", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            #region Functions/Actions
            var giftCardAmountFunction = new EdmFunction(ns, "GetActualAmount", EdmCoreModel.Instance.GetDouble(false), true, null, false);
            giftCardAmountFunction.AddParameter("giftcard", new EdmEntityTypeReference(giftCardType, false));
            giftCardAmountFunction.AddParameter("bonusRate", EdmCoreModel.Instance.GetDouble(true));
            model.AddElement(giftCardAmountFunction);

            var accountDefaultPIFunction = new EdmFunction(ns, "GetDefaultPI", new EdmEntityTypeReference(paymentInstrumentType, true), true, new EdmPathExpression("account/MyPaymentInstruments"), false);
            accountDefaultPIFunction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            model.AddElement(accountDefaultPIFunction);

            var accountRefreshDefaultPIAction = new EdmAction(ns, "RefreshDefaultPI", new EdmEntityTypeReference(paymentInstrumentType, true), true, new EdmPathExpression("account/MyPaymentInstruments"));
            accountRefreshDefaultPIAction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            accountRefreshDefaultPIAction.AddParameter("newDate", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(accountRefreshDefaultPIAction);

            //Bound Function : Bound to Entity, Return ComplexType
            var getHomeAddressFunction = new EdmFunction(ns, "GetHomeAddress",
                new EdmComplexTypeReference(homeAddressType, false),
                true, null, true);
            getHomeAddressFunction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            model.AddElement(getHomeAddressFunction);

            //Bound Function : Bound to Entity, Return ComplexType
            var getAccountInfoFunction = new EdmFunction(ns, "GetAccountInfo",
                new EdmComplexTypeReference(accountInfoType, false),
                true, null, true);
            getAccountInfoFunction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            model.AddElement(getAccountInfoFunction);

            #endregion

            var accountGiftCardNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyGiftCard",
                Target = giftCardType,
                TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                ContainsTarget = true
            });

            var accountPIsNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyPaymentInstruments",
                Target = paymentInstrumentType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var accountActiveSubsNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "ActiveSubscriptions",
                Target = subscriptionType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var accountAvailableSubsTemplatesNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "AvailableSubscriptionTemplatess",
                Target = subscriptionType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = false
            });

            var piStoredNavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "TheStoredPI",
                Target = storedPIType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = false
            });

            var piStatementsNavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "BillingStatements",
                Target = statementType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var piBackupStoredPINavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "BackupStoredPI",
                Target = storedPIType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = false
            });

            var creditCardCreditRecordNavigation = creditCardType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "CreditRecords",
                Target = creditRecordType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            model.AddElement(accountInfoType);
            model.AddElement(accountType);
            model.AddElement(giftCardType);
            model.AddElement(paymentInstrumentType);
            model.AddElement(creditCardType);
            model.AddElement(storedPIType);
            model.AddElement(statementType);
            model.AddElement(creditRecordType);
            model.AddElement(subscriptionType);

            var accountSet = new EdmEntitySet(defaultContainer, "Accounts", accountType);
            defaultContainer.AddElement(accountSet);
            var storedPISet = new EdmEntitySet(defaultContainer, "StoredPIs", storedPIType);
            defaultContainer.AddElement(storedPISet);
            var subscriptionTemplatesSet = new EdmEntitySet(defaultContainer, "SubscriptionTemplates", subscriptionType);
            defaultContainer.AddElement(subscriptionTemplatesSet);
            var defaultStoredPI = new EdmSingleton(defaultContainer, "DefaultStoredPI", storedPIType);
            defaultContainer.AddElement(defaultStoredPI);

            ((EdmEntitySet)accountSet).AddNavigationTarget(piStoredNavigation, storedPISet);
            ((EdmEntitySet)accountSet).AddNavigationTarget(accountAvailableSubsTemplatesNavigation, subscriptionTemplatesSet);
            ((EdmEntitySet)accountSet).AddNavigationTarget(piBackupStoredPINavigation, defaultStoredPI);

            #endregion

            IEnumerable<EdmError> errors = null;
            model.Validate(out errors);
            //TODO: Fix the errors

            return model;
        }
        public static EdmModel NavigationPropertyWithAnnotationModel()
        {
            EdmModel model = new EdmModel();

            EdmEntityType person = new EdmEntityType("DefaultNamespace", "Person");
            EdmStructuralProperty personId = person.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            person.AddKeys(personId);
            model.AddElement(person);

            EdmNavigationProperty friend = person.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Friends", Target = person, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "Self", TargetMultiplicity = EdmMultiplicity.One });
            IEdmNavigationProperty self = friend.Partner;

            XElement annotationElement =
                new XElement("{http://foo}Annotation", "1");
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            annotation.SetIsSerializedAsElement(model, true);
            model.SetAnnotationValue(friend, "http://foo", "Annotation", annotation);

            return model;
        }
        public static IEdmModel ModelWithAssociationEndAsInaccessibleEntityType()
        {
            EdmModel model = new EdmModel();

            var entity1 = new EdmEntityType("Foo", "Bar");
            entity1.AddKeys(entity1.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None));


            var entity2 = new EdmEntityType("Foo", "Baz");
            entity2.AddKeys(entity2.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None));

            EdmNavigationProperty entity1Navigation = entity1.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ToBaz", Target = entity2, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "ToBar", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            model.AddElement(entity1);

            return model;
        }
Esempio n. 14
0
        public static IEdmModel AssociationOnDeleteModelEdm()
        {
            var model = new EdmModel();
            var customerType = new EdmEntityType("NS1", "Customer");
            customerType.AddKeys(customerType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(customerType);

            var orderType = new EdmEntityType("NS1", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(orderType);

            var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32);
            var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade };
            var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key(), OnDelete = EdmOnDeleteAction.None };
            customerType.AddBidirectionalNavigation(navProp1, navProp2);

            return model;
        }
Esempio n. 15
0
        internal static IEdmModel GetEdmModel()
        {
            var model = new EdmModel();

            #region Type Definitions

            var FullyQualifiedNamespaceIdType = new EdmTypeDefinition("Fully.Qualified.Namespace", "IdType", EdmPrimitiveTypeKind.Double);
            var FullyQualifiedNamespaceIdTypeReference = new EdmTypeDefinitionReference(FullyQualifiedNamespaceIdType, false);
            model.AddElement(FullyQualifiedNamespaceIdType);

            var FullyQualifiedNamespaceNameType = new EdmTypeDefinition("Fully.Qualified.Namespace", "NameType", EdmPrimitiveTypeKind.String);
            var FullyQualifiedNamespaceNameTypeReference = new EdmTypeDefinitionReference(FullyQualifiedNamespaceNameType, false);
            model.AddElement(FullyQualifiedNamespaceNameType);

            var FullyQualifiedNamespaceUInt16Reference = model.GetUInt16("Fully.Qualified.Namespace", false);
            var FullyQualifiedNamespaceUInt32Reference = model.GetUInt32("Fully.Qualified.Namespace", false);
            var FullyQualifiedNamespaceUInt64Reference = model.GetUInt64("Fully.Qualified.Namespace", false);

            #endregion

            #region Enum Types
            var colorType = new EdmEnumType("Fully.Qualified.Namespace", "ColorPattern", EdmPrimitiveTypeKind.Int64, true);
            colorType.AddMember("Red", new EdmIntegerConstant(1L));
            colorType.AddMember("Blue", new EdmIntegerConstant(2L));
            colorType.AddMember("Yellow", new EdmIntegerConstant(4L));
            colorType.AddMember("Solid", new EdmIntegerConstant(8L));
            colorType.AddMember("Striped", new EdmIntegerConstant(16L));
            colorType.AddMember("SolidRed", new EdmIntegerConstant(9L));
            colorType.AddMember("SolidBlue", new EdmIntegerConstant(10L));
            colorType.AddMember("SolidYellow", new EdmIntegerConstant(12L));
            colorType.AddMember("RedBlueStriped", new EdmIntegerConstant(19L));
            colorType.AddMember("RedYellowStriped", new EdmIntegerConstant(21L));
            colorType.AddMember("BlueYellowStriped", new EdmIntegerConstant(22L));
            model.AddElement(colorType);
            var colorTypeReference = new EdmEnumTypeReference(colorType, false);
            var nullableColorTypeReference = new EdmEnumTypeReference(colorType, true);

            var NonFlagShapeType = new EdmEnumType("Fully.Qualified.Namespace", "NonFlagShape", EdmPrimitiveTypeKind.SByte, false);
            NonFlagShapeType.AddMember("Rectangle", new EdmIntegerConstant(1));
            NonFlagShapeType.AddMember("Triangle", new EdmIntegerConstant(2));
            NonFlagShapeType.AddMember("foursquare", new EdmIntegerConstant(3));
            model.AddElement(NonFlagShapeType);
            #endregion

            #region Structured Types
            var FullyQualifiedNamespacePerson = new EdmEntityType("Fully.Qualified.Namespace", "Person", null, false, false);
            var FullyQualifiedNamespaceEmployee = new EdmEntityType("Fully.Qualified.Namespace", "Employee", FullyQualifiedNamespacePerson, false, false);
            var FullyQualifiedNamespaceManager = new EdmEntityType("Fully.Qualified.Namespace", "Manager", FullyQualifiedNamespaceEmployee, false, false);
            var FullyQualifiedNamespaceOpenEmployee = new EdmEntityType("Fully.Qualified.Namespace", "OpenEmployee", FullyQualifiedNamespaceEmployee, false, true);
            var FullyQualifiedNamespaceDog = new EdmEntityType("Fully.Qualified.Namespace", "Dog", null, false, false);
            var FullyQualifiedNamespaceLion = new EdmEntityType("Fully.Qualified.Namespace", "Lion", null, false, false);
            var FullyQualifiedNamespaceChimera = new EdmEntityType("Fully.Qualified.Namespace", "Chimera", null, false, true);
            var FullyQualifiedNamespacePainting = new EdmEntityType("Fully.Qualified.Namespace", "Painting", null, false, true);
            var FullyQualifiedNamespaceFramedPainting = new EdmEntityType("Fully.Qualified.Namespace", "FramedPainting", FullyQualifiedNamespacePainting, false, true);
            var FullyQualifiedNamespaceUserAccount = new EdmEntityType("Fully.Qualified.Namespace", "UserAccount", null, false, false);
            var FullyQualifiedNamespacePet1 = new EdmEntityType("Fully.Qualified.Namespace", "Pet1", null, false, false);
            var FullyQualifiedNamespacePet2 = new EdmEntityType("Fully.Qualified.Namespace", "Pet2", null, false, false);
            var FullyQualifiedNamespacePet3 = new EdmEntityType("Fully.Qualified.Namespace", "Pet3", null, false, false);
            var FullyQualifiedNamespacePet4 = new EdmEntityType("Fully.Qualified.Namespace", "Pet4", null, false, false);
            var FullyQualifiedNamespacePet5 = new EdmEntityType("Fully.Qualified.Namespace", "Pet5", null, false, false);
            var FullyQualifiedNamespacePet6 = new EdmEntityType("Fully.Qualified.Namespace", "Pet6", null, false, false);

            var FullyQualifiedNamespaceAddress = new EdmComplexType("Fully.Qualified.Namespace", "Address");
            var FullyQualifiedNamespaceOpenAddress = new EdmComplexType("Fully.Qualified.Namespace", "OpenAddress", null, false, true);
            var FullyQualifiedNamespaceHomeAddress = new EdmComplexType("Fully.Qualified.Namespace", "HomeAddress", FullyQualifiedNamespaceAddress);

            var FullyQualifiedNamespacePersonTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePerson, true);
            var FullyQualifiedNamespaceEmployeeTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceEmployee, true);
            var FullyQualifiedNamespaceManagerTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceManager, true);
            var FullyQualifiedNamespaceOpenEmployeeTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceOpenEmployee, true);
            var FullyQualifiedNamespaceDogTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceDog, true);
            var FullyQualifiedNamespaceLionTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceLion, true);
            var FullyQualifiedNamespacePet1TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet1, true);
            var FullyQualifiedNamespacePet2TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet2, true);
            var FullyQualifiedNamespacePet3TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet3, true);
            var FullyQualifiedNamespacePet4TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet4, true);
            var FullyQualifiedNamespacePet5TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet5, true);
            var FullyQualifiedNamespacePet6TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet6, true);
            var FullyQualifiedNamespacePaintingTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePainting, true);
            var FullyQualifiedNamespaceFramedPaintingTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceFramedPainting, true);
            var FullyQualifiedNamespaceUserAccountTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceUserAccount, true);

            var FullyQualifiedNamespaceLion_ID1 = FullyQualifiedNamespaceLion.AddStructuralProperty("ID1", EdmCoreModel.Instance.GetInt32(false));
            var FullyQualifiedNamespaceLion_ID2 = FullyQualifiedNamespaceLion.AddStructuralProperty("ID2", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespaceLion.AddStructuralProperty("AngerLevel", EdmCoreModel.Instance.GetDouble(true));
            FullyQualifiedNamespaceLion.AddStructuralProperty("AttackDates", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDateTimeOffset(true))));
            FullyQualifiedNamespaceLion.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceLion_ID1, FullyQualifiedNamespaceLion_ID2, });
            model.AddElement(FullyQualifiedNamespaceLion);

            var FullyQualifiedNamespaceAddressTypeReference = new EdmComplexTypeReference(FullyQualifiedNamespaceAddress, true);
            var FullyQualifiedNamespaceOpenAddressTypeReference = new EdmComplexTypeReference(FullyQualifiedNamespaceOpenAddress, true);
            var FullyQualifiedNamespacePerson_ID = FullyQualifiedNamespacePerson.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            var FullyQualifiedNamespacePerson_SSN = FullyQualifiedNamespacePerson.AddStructuralProperty("SSN", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("Shoe", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyPoint", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyLineString", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyLineString, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyPolygon", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPolygon, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryPoint", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryLineString", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryLineString, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryPolygon", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPolygon, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true))));
            var FullyQualifiedNamespacePerson_Name = FullyQualifiedNamespacePerson.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true));
            var FullyQualifiedNamespacePerson_FirstName = FullyQualifiedNamespacePerson.AddStructuralProperty("FirstName", FullyQualifiedNamespaceNameTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("Prop.With.Periods", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyDate", EdmCoreModel.Instance.GetDate(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyDates", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDate(true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyTimeOfDay", EdmCoreModel.Instance.GetTimeOfDay(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyTimeOfDays", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetTimeOfDay(true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("Birthdate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteDate", EdmCoreModel.Instance.GetDateTimeOffset(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("TimeEmployed", EdmCoreModel.Instance.GetDuration(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyAddress", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyOpenAddress", FullyQualifiedNamespaceOpenAddressTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("PreviousAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteNumber", FullyQualifiedNamespaceUInt16Reference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("StockQuantity", FullyQualifiedNamespaceUInt32Reference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("LifeTime", FullyQualifiedNamespaceUInt64Reference);
            FullyQualifiedNamespacePerson.AddKeys(FullyQualifiedNamespacePerson_ID);
            var FullyQualifiedNamespacePerson_MyDog = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyDog", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespaceDog });
            var FullyQualifiedNamespacePerson_MyRelatedDogs = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyFriendsDogs", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespaceDog });
            var FullyQualifiedNamespacePerson_MyPaintings = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPaintings", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespacePerson_MyFavoritePainting = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyFavoritePainting", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespacePerson_MyLions = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyLions",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = FullyQualifiedNamespaceLion,
                DependentProperties = new List<IEdmStructuralProperty>()
                {
                    FullyQualifiedNamespacePerson_ID
                },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                {
                    FullyQualifiedNamespaceLion_ID1
                }
            });
            FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo
                {
                    Name = "MyContainedDog",
                    TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                    Target = FullyQualifiedNamespaceDog,
                    ContainsTarget = true
                });
            FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo
                {
                    Name = "MyContainedChimeras",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceChimera,
                    ContainsTarget = true
                });

            var FullyQualifiedNamespacePerson_MyPet2Set = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPet2Set", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePet2, });

            model.AddAlternateKeyAnnotation(FullyQualifiedNamespacePerson, new Dictionary<string, IEdmProperty>()
            {
                {"SocialSN", FullyQualifiedNamespacePerson_SSN}
            });

            model.AddAlternateKeyAnnotation(FullyQualifiedNamespacePerson, new Dictionary<string, IEdmProperty>()
            {
                {"NameAlias", FullyQualifiedNamespacePerson_Name},
                {"FirstNameAlias", FullyQualifiedNamespacePerson_FirstName}
            });

            model.AddElement(FullyQualifiedNamespacePerson);

            FullyQualifiedNamespaceEmployee.AddStructuralProperty("WorkEmail", EdmCoreModel.Instance.GetString(true));
            var FullyQualifiedNamespaceEmployee_PaintingsInOffice = FullyQualifiedNamespaceEmployee.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "PaintingsInOffice", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespaceEmployee_Manager = FullyQualifiedNamespaceEmployee.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Manager", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespaceManager });
            var FullyQualifiedNamespaceEmployee_OfficeDog = FullyQualifiedNamespaceDog.AddBidirectionalNavigation
                (
                    new EdmNavigationPropertyInfo()
                    {
                        Name = "EmployeeOwner",
                        TargetMultiplicity = EdmMultiplicity.One,
                        Target = FullyQualifiedNamespaceEmployee
                    },

                    new EdmNavigationPropertyInfo()
                    {
                        Name = "OfficeDog",
                        TargetMultiplicity = EdmMultiplicity.One,
                        Target = FullyQualifiedNamespaceDog
                    }
                );
            model.AddElement(FullyQualifiedNamespaceEmployee);

            FullyQualifiedNamespaceManager.AddStructuralProperty("NumberOfReports", EdmCoreModel.Instance.GetInt32(true));
            var FullyQualifiedNamespaceManager_DirectReports = FullyQualifiedNamespaceManager.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "DirectReports", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespaceEmployee });
            model.AddElement(FullyQualifiedNamespaceManager);

            model.AddElement(FullyQualifiedNamespaceOpenEmployee);

            var FullyQualifiedNamespaceDog_ID = FullyQualifiedNamespaceDog.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Color", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Nicknames", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Breed", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceDog.AddStructuralProperty("NamedStream", EdmCoreModel.Instance.GetStream(true));
            FullyQualifiedNamespaceDog.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceDog_ID, });
            var FullyQualifiedNamespaceDog_MyPeople = FullyQualifiedNamespaceDog.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPeople", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePerson });
            var FullyQualifiedNamespaceDog_FastestOwner = FullyQualifiedNamespaceDog.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "FastestOwner", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePerson });
            var FullyQualifiedNamespaceDog_LionWhoAteMe = FullyQualifiedNamespaceDog.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "LionWhoAteMe",
                    TargetMultiplicity = EdmMultiplicity.One,
                    Target = FullyQualifiedNamespaceLion,
                },
                new EdmNavigationPropertyInfo()
                {
                    Name = "DogThatIAte",
                    TargetMultiplicity = EdmMultiplicity.One,
                    Target = FullyQualifiedNamespaceDog,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID1
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceDog_ID
                    }
                });
            var FullyQualifiedNamespaceDog_LionsISaw = FullyQualifiedNamespaceDog.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "LionsISaw",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceLion,
                },
                new EdmNavigationPropertyInfo()
                {
                    Name = "DogsSeenMe",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceDog,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID1
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceDog_ID
                    }
                });
            var FullyQualifiedNamespaceLion_Friends = FullyQualifiedNamespaceLion.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "Friends",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceLion,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID2
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceLion_ID1
                    }
                });
            model.AddElement(FullyQualifiedNamespaceDog);

            var fullyQualifiedNamespaceChimeraKey1 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Rid", EdmCoreModel.Instance.GetInt32(false));
            var fullyQualifiedNamespaceChimeraKey2 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Gid", EdmPrimitiveTypeKind.Guid);
            var fullyQualifiedNamespaceChimeraKey3 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            var fullyQualifiedNamespaceChimeraKey4 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Upgraded", EdmPrimitiveTypeKind.Boolean);
            FullyQualifiedNamespaceChimera.AddStructuralProperty("Level", EdmPrimitiveTypeKind.Int32);
            FullyQualifiedNamespaceChimera.AddKeys(new IEdmStructuralProperty[] { fullyQualifiedNamespaceChimeraKey1, fullyQualifiedNamespaceChimeraKey2, fullyQualifiedNamespaceChimeraKey3, fullyQualifiedNamespaceChimeraKey4 });
            model.AddElement(FullyQualifiedNamespaceChimera);

            var FullyQualifiedNamespacePainting_ID = FullyQualifiedNamespacePainting.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Artist", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Value", EdmCoreModel.Instance.GetDecimal(true));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Colors", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            FullyQualifiedNamespacePainting.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespacePainting_ID, });
            var FullyQualifiedNamespacePainting_Owner = FullyQualifiedNamespacePainting.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Owner", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePerson });
            model.AddElement(FullyQualifiedNamespacePainting);

            FullyQualifiedNamespaceFramedPainting.AddStructuralProperty("FrameColor", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceFramedPainting);

            var FullyQualifiedNamespaceUserAccount_UserName = FullyQualifiedNamespaceUserAccount.AddStructuralProperty("UserName", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceUserAccount.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceUserAccount_UserName, });
            model.AddElement(FullyQualifiedNamespaceUserAccount);

            FullyQualifiedNamespaceAddress.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceAddress.AddStructuralProperty("City", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceAddress.AddStructuralProperty("NextHome", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespaceAddress.AddStructuralProperty("MyNeighbors", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            model.AddElement(FullyQualifiedNamespaceAddress);

            FullyQualifiedNamespaceHomeAddress.AddStructuralProperty("HomeNO", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceHomeAddress);

            model.AddElement(FullyQualifiedNamespaceOpenAddress);

            FullyQualifiedNamespacePet1.AddKeys(FullyQualifiedNamespacePet1.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int64, false));
            FullyQualifiedNamespacePet1.AddStructuralProperty("SingleID", EdmPrimitiveTypeKind.Single, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("DoubleID", EdmPrimitiveTypeKind.Double, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("DecimalID", EdmPrimitiveTypeKind.Decimal, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet1);

            FullyQualifiedNamespacePet2.AddKeys(FullyQualifiedNamespacePet2.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Single, false));
            FullyQualifiedNamespacePet2.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            FullyQualifiedNamespacePet2.AddStructuralProperty("PetColorPattern", colorTypeReference);
            model.AddElement(FullyQualifiedNamespacePet2);

            FullyQualifiedNamespacePet3.AddKeys(FullyQualifiedNamespacePet3.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Double, false));
            FullyQualifiedNamespacePet3.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet3);

            FullyQualifiedNamespacePet4.AddKeys(FullyQualifiedNamespacePet4.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Decimal, false));
            FullyQualifiedNamespacePet4.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet4);

            FullyQualifiedNamespacePet5.AddKeys(FullyQualifiedNamespacePet5.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Boolean, false));
            FullyQualifiedNamespacePet5.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet5);

            FullyQualifiedNamespacePet6.AddKeys(FullyQualifiedNamespacePet6.AddStructuralProperty("ID", FullyQualifiedNamespaceIdTypeReference));
            FullyQualifiedNamespacePet6.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet6);
            #endregion

            #region Operations

            var FullyQualifiedNamespaceGetPet1Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet1", FullyQualifiedNamespacePet1TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet1Function.AddParameter("id", EdmCoreModel.Instance.GetInt64(false));
            model.AddElement(FullyQualifiedNamespaceGetPet1Function);

            var FullyQualifiedNamespaceGetPet2Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet2", FullyQualifiedNamespacePet2TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet2Function.AddParameter("id", EdmCoreModel.Instance.GetSingle(false));
            model.AddElement(FullyQualifiedNamespaceGetPet2Function);

            var FullyQualifiedNamespaceGetPet3Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet3", FullyQualifiedNamespacePet3TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet3Function.AddParameter("id", EdmCoreModel.Instance.GetDouble(false));
            model.AddElement(FullyQualifiedNamespaceGetPet3Function);

            var FullyQualifiedNamespaceGetPet4Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet4", FullyQualifiedNamespacePet4TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet4Function.AddParameter("id", EdmCoreModel.Instance.GetDecimal(false));
            model.AddElement(FullyQualifiedNamespaceGetPet4Function);

            var FullyQualifiedNamespaceGetPet5Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet5", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet5Function.AddParameter("id", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(FullyQualifiedNamespaceGetPet5Function);

            var FullyQualifiedNamespaceGetPet6Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet6", FullyQualifiedNamespacePet6TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet6Function.AddParameter("id", FullyQualifiedNamespaceIdTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPet6Function);

            var FullyQualifiedNamespaceGetPetCountFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPetCount", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPetCountFunction.AddParameter("colorPattern", colorTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPetCountFunction);

            var FullyQualifiedNamespaceTryGetPetCountFunction = new EdmFunction("Fully.Qualified.Namespace", "TryGetPetCount", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPetCountFunction.AddParameter("colorPattern", nullableColorTypeReference);
            model.AddElement(FullyQualifiedNamespaceTryGetPetCountFunction);

            var FullyQualifiedNamespaceWalkAction = new EdmAction("Fully.Qualified.Namespace", "Walk", FullyQualifiedNamespaceAddressTypeReference, true, null);
            FullyQualifiedNamespaceWalkAction.AddParameter("dog", FullyQualifiedNamespaceDogTypeReference);
            model.AddElement(FullyQualifiedNamespaceWalkAction);

            var FullyQualifiedNamespaceFindMyOwnerFunction = new EdmFunction("Fully.Qualified.Namespace", "FindMyOwner", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            FullyQualifiedNamespaceFindMyOwnerFunction.AddParameter("dogsName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceFindMyOwnerFunction);

            var FullyQualifiedNamespaceHasHatFunction = new EdmFunction("Fully.Qualified.Namespace", "HasHat", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasHatFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasHatFunction);

            var FullyQualifiedNamespaceHasHatFunction2 = new EdmFunction("Fully.Qualified.Namespace", "HasHat", EdmCoreModel.Instance.GetInt32(true), true, null, false);
            FullyQualifiedNamespaceHasHatFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasHatFunction2.AddParameter("onCat", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasHatFunction2);

            var FullyQualifiedNamespaceHasJobFunction = new EdmFunction("Fully.Qualified.Namespace", "HasJob", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasJobFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasJobFunction);

            var FullyQualifiedNamespaceAllHaveDogFunction = new EdmFunction("Fully.Qualified.Namespace", "AllHaveDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceAllHaveDogFunction.AddParameter("people", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            model.AddElement(FullyQualifiedNamespaceAllHaveDogFunction);

            var FullyQualifiedNamespaceAllHaveDogFunction2 = new EdmFunction("Fully.Qualified.Namespace", "AllHaveDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceAllHaveDogFunction2.AddParameter("people", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            FullyQualifiedNamespaceAllHaveDogFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceAllHaveDogFunction2);

            var FullyQualifiedNamespaceFireAllAction = new EdmAction("Fully.Qualified.Namespace", "FireAll", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceFireAllAction.AddParameter("employees", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            model.AddElement(FullyQualifiedNamespaceFireAllAction);

            var FullyQualifiedNamespaceHasDogFunction = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasDogFunction);

            var FullyQualifiedNamespaceHasDogFunction2 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasDogFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction2);

            var FullyQualifiedNamespaceHasDogFunction3 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("name", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction3);

            var FullyQualifiedNamespaceHasDogFunction4 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction4.AddParameter("person", FullyQualifiedNamespaceEmployeeTypeReference);
            FullyQualifiedNamespaceHasDogFunction4.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction4);

            var FullyQualifiedNamespaceGetMyDogFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMyDog", FullyQualifiedNamespaceDogTypeReference, true, new EdmPathExpression("person/MyDog"), true);
            FullyQualifiedNamespaceGetMyDogFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetMyDogFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), true);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogsNonComposable", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), false);
            FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsFunction2 = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), true);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsFunction2);

            var FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs_NoSet", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, null, false);
            FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction);

            var FullyQualifiedNamespaceOwnerOfFastestDogFunction = new EdmFunction("Fully.Qualified.Namespace", "OwnerOfFastestDog", FullyQualifiedNamespacePersonTypeReference, true, new EdmPathExpression("dogs/FastestOwner"), true);
            FullyQualifiedNamespaceOwnerOfFastestDogFunction.AddParameter("dogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)));
            model.AddElement(FullyQualifiedNamespaceOwnerOfFastestDogFunction);

            var FullyQualifiedNamespaceOwnsTheseDogsFunction = new EdmFunction("Fully.Qualified.Namespace", "OwnsTheseDogs", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceOwnsTheseDogsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceOwnsTheseDogsFunction.AddParameter("dogNames", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            model.AddElement(FullyQualifiedNamespaceOwnsTheseDogsFunction);

            var FullyQualifiedNamespaceIsInTheUSFunction = new EdmFunction("Fully.Qualified.Namespace", "IsInTheUS", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsInTheUSFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceIsInTheUSFunction);

            var FullyQualifiedNamespaceMoveAction = new EdmAction("Fully.Qualified.Namespace", "Move", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceMoveAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceMoveAction.AddParameter("streetAddress", EdmCoreModel.Instance.GetString(true));

            var FullyQualifiedNamespaceCanMoveToAddressFunction = new EdmFunction("Fully.Qualified.Namespace", "CanMoveToAddress", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceCanMoveToAddressFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceCanMoveToAddressFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceCanMoveToAddressFunction);

            var FullyQualifiedNamespaceIsAddressGoodFunction = new EdmFunction("Fully.Qualified.Namespace", "IsAddressGood", EdmCoreModel.Instance.GetBoolean(true), false, null, false);
            FullyQualifiedNamespaceIsAddressGoodFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceIsAddressGoodFunction);

            var FullyQualifiedNamespaceCanMoveToAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "CanMoveToAddresses", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceCanMoveToAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceCanMoveToAddressesFunction.AddParameter("addresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)));
            model.AddElement(FullyQualifiedNamespaceCanMoveToAddressesFunction);

            var FullyQualifiedNamespaceIsOlderThanByteFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanByte", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanByteFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanByteFunction.AddParameter("age", EdmCoreModel.Instance.GetByte(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanByteFunction);

            var FullyQualifiedNamespaceIsOlderThanSByteFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanSByte", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanSByteFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanSByteFunction.AddParameter("age", EdmCoreModel.Instance.GetSByte(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanSByteFunction);

            var FullyQualifiedNamespaceIsOlderThanShortFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanShort", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanShortFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanShortFunction.AddParameter("age", EdmCoreModel.Instance.GetInt16(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanShortFunction);

            var FullyQualifiedNamespaceIsOlderThanSingleFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanSingle", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanSingleFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanSingleFunction.AddParameter("age", EdmCoreModel.Instance.GetSingle(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanSingleFunction);

            var FullyQualifiedNamespacePaintAction = new EdmAction("Fully.Qualified.Namespace", "Paint", FullyQualifiedNamespacePaintingTypeReference, true, new EdmPathExpression("person/MyPaintings"));
            FullyQualifiedNamespacePaintAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespacePaintAction);

            var FullyQualifiedNamespaceMoveAction2 = new EdmAction("Fully.Qualified.Namespace", "Move", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceMoveAction2.AddParameter("employee", FullyQualifiedNamespaceEmployeeTypeReference);
            FullyQualifiedNamespaceMoveAction2.AddParameter("building", EdmCoreModel.Instance.GetInt32(true));
            FullyQualifiedNamespaceMoveAction2.AddParameter("room", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceMoveAction2);

            var FullyQualifiedNamespaceRestoreAction = new EdmAction("Fully.Qualified.Namespace", "Restore", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceRestoreAction.AddParameter("painting", FullyQualifiedNamespacePaintingTypeReference);
            model.AddElement(FullyQualifiedNamespaceRestoreAction);

            var FullyQualifiedNamespaceChangeStateAction = new EdmAction("Fully.Qualified.Namespace", "ChangeState", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceChangeStateAction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespaceChangeStateAction.AddParameter("newState", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceChangeStateAction);

            var FullyQualifiedNamespaceGetMyPersonFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMyPerson", FullyQualifiedNamespacePersonTypeReference, true, null, false);
            FullyQualifiedNamespaceGetMyPersonFunction.AddParameter("dog", FullyQualifiedNamespaceDogTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetMyPersonFunction);
            model.AddElement(FullyQualifiedNamespaceMoveAction);

            var FullyQualifiedNamespaceGetCoolPeopleAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolPeople", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)), false, null, true /*isComposable*/);
            FullyQualifiedNamespaceGetCoolPeopleAction.AddParameter("id", EdmCoreModel.Instance.GetInt32(true));
            FullyQualifiedNamespaceGetCoolPeopleAction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetCoolPeopleAction);

            var FullyQualifiedNamespaceGetHotPeopleAction = new EdmFunction("Fully.Qualified.Namespace", "GetHotPeople", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)), true, new EdmPathExpression("person"), true /*isComposable*/);
            FullyQualifiedNamespaceGetHotPeopleAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetHotPeopleAction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetHotPeopleAction);

            var FullyQualifiedNamespaceGetCoolestPersonAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolestPerson", FullyQualifiedNamespacePersonTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetCoolestPersonAction);

            var FullyQualifiedNamespaceGetCoolestPersonWithStyleAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolestPersonWithStyle", FullyQualifiedNamespacePersonTypeReference, false, null, true /*isComposable*/);
            FullyQualifiedNamespaceGetCoolestPersonWithStyleAction.AddParameter("styleID", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetCoolestPersonWithStyleAction);

            var FullyQualifiedNamespaceGetBestManagerAction = new EdmFunction("Fully.Qualified.Namespace", "GetBestManager", FullyQualifiedNamespaceManagerTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetBestManagerAction);

            var FullyQualifiedNamespaceGetNothingAction = new EdmAction("Fully.Qualified.Namespace", "GetNothing", null, false, null);
            model.AddElement(FullyQualifiedNamespaceGetNothingAction);

            var FullyQualifiedNamespaceGetSomeNumberAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeNumber", EdmCoreModel.Instance.GetInt32(true), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeNumberAction);

            var FullyQualifiedNamespaceGetSomeAddressAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeAddress", FullyQualifiedNamespaceAddressTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeAddressAction);

            var FullyQualifiedNamespaceGetSomeNumbersAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt32(true))), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeNumbersAction);

            var FullyQualifiedNamespaceGetSomeColorsFunction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeColorsFunction);

            var FullyQualifiedNamespaceGetSomeColorFunction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeColor", colorTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeColorFunction);

            var FullyQualifiedNamespaceGetSomeAddressesAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeAddressesAction);

            var FullyQualifiedNamespaceResetAllDataAction = new EdmAction("Fully.Qualified.Namespace", "ResetAllData", null, false, null);
            model.AddElement(FullyQualifiedNamespaceResetAllDataAction);

            var FullyQualifiedNamespaceGetMostImporantPersonFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMostImporantPerson", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            model.AddElement(FullyQualifiedNamespaceGetMostImporantPersonFunction);

            var FullyQualifiedNamespaceGetMostImporantPersonFunction2 = new EdmFunction("Fully.Qualified.Namespace", "GetMostImporantPerson", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            FullyQualifiedNamespaceGetMostImporantPersonFunction2.AddParameter("city", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceGetMostImporantPersonFunction2);

            var FullyQualifiedNamespaceGetPriorNumbersFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt32(true))), true, null, true);
            FullyQualifiedNamespaceGetPriorNumbersFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorNumbersFunction);

            var FullyQualifiedNamespaceGetPriorAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), true, null, true);
            FullyQualifiedNamespaceGetPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorAddressesFunction);

            var FullyQualifiedNamespaceGetPriorAddressFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorAddress", FullyQualifiedNamespaceAddressTypeReference, true, null, true);
            FullyQualifiedNamespaceGetPriorAddressFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorAddressFunction);

            var FullyQualifiedNamespaceGetFavoriteColorsFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFavoriteColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)), true, null, true);
            FullyQualifiedNamespaceGetFavoriteColorsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFavoriteColorsFunction);

            var FullyQualifiedNamespaceGetFavoriteColorFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFavoriteColor", colorTypeReference, true, null, true);
            FullyQualifiedNamespaceGetFavoriteColorFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFavoriteColorFunction);

            var FullyQualifiedNamespaceGetNearbyPriorAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "GetNearbyPriorAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), true, null, false);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("currentLocation", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true));
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetNearbyPriorAddressesFunction);

            var FullyQualifiedNamespaceGetColorAtPositionFunction = new EdmFunction("Fully.Qualified.Namespace", "GetColorAtPosition", EdmCoreModel.Instance.GetString(true), true, null, false);
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("painting", FullyQualifiedNamespacePaintingTypeReference);
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("position", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true));
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("includeAlpha", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceGetColorAtPositionFunction);

            var FullyQualifiedNamespaceMoveEveryoneAction = new EdmAction("Fully.Qualified.Namespace", "MoveEveryone", EdmCoreModel.Instance.GetBoolean(true), false, null);
            FullyQualifiedNamespaceMoveEveryoneAction.AddParameter("streetAddress", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceMoveEveryoneAction);

            var FullyQualifiedNamespaceGetFullNameFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFullName", FullyQualifiedNamespaceNameTypeReference, true, null, true);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetFullNameFunction.AddParameter("nickname", FullyQualifiedNamespaceNameTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFullNameFunction);

            #endregion

            #region Context Container

            var FullyQualifiedNamespaceContext = new EdmEntityContainer("Fully.Qualified.Namespace", "Context");
            model.AddElement(FullyQualifiedNamespaceContext);

            var FullyQualifiedNamespaceContextPeople = FullyQualifiedNamespaceContext.AddEntitySet("People", FullyQualifiedNamespacePerson);
            var FullyQualifiedNamespaceContextDogs = FullyQualifiedNamespaceContext.AddEntitySet("Dogs", FullyQualifiedNamespaceDog);
            var FullyQualifiedNamespaceContextLions = FullyQualifiedNamespaceContext.AddEntitySet("Lions", FullyQualifiedNamespaceLion);
            var FullyQualifiedNamespaceContextPaintings = FullyQualifiedNamespaceContext.AddEntitySet("Paintings", FullyQualifiedNamespacePainting);
            var FullyQualifiedNamespaceContextUsers = FullyQualifiedNamespaceContext.AddEntitySet("Users", FullyQualifiedNamespaceUserAccount);
            var FullyQualifiedNamespaceContextPet1Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet1Set", FullyQualifiedNamespacePet1);
            var FullyQualifiedNamespaceContextPet2Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet2Set", FullyQualifiedNamespacePet2);
            var FullyQualifiedNamespaceContextPet3Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet3Set", FullyQualifiedNamespacePet3);
            var FullyQualifiedNamespaceContextPet4Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet4Set", FullyQualifiedNamespacePet4);
            var FullyQualifiedNamespaceContextPet5Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet5Set", FullyQualifiedNamespacePet5);
            var FullyQualifiedNamespaceContextPet6Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet6Set", FullyQualifiedNamespacePet6);
            var FullyQualifiedNamespaceContextChimera = FullyQualifiedNamespaceContext.AddEntitySet("Chimeras", FullyQualifiedNamespaceChimera);

            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyRelatedDogs, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyLions, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyFavoritePainting, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_PaintingsInOffice, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_Manager, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceManager_DirectReports, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPet2Set, FullyQualifiedNamespaceContextPet2Set);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_MyPeople, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_FastestOwner, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_LionsISaw, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextLions.AddNavigationTarget(FullyQualifiedNamespaceLion_Friends, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPaintings.AddNavigationTarget(FullyQualifiedNamespacePainting_Owner, FullyQualifiedNamespaceContextPeople);

            // Add singleton
            var FullQualifiedNamespaceSingletonBoss = FullyQualifiedNamespaceContext.AddSingleton("Boss", FullyQualifiedNamespacePerson);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet1", FullyQualifiedNamespaceGetPet1Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet1Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet2", FullyQualifiedNamespaceGetPet2Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet2Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet3", FullyQualifiedNamespaceGetPet3Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet3Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet4", FullyQualifiedNamespaceGetPet4Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet4Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet5", FullyQualifiedNamespaceGetPet5Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet6", FullyQualifiedNamespaceGetPet6Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet6Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPetCount", FullyQualifiedNamespaceGetPetCountFunction, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));

            FullyQualifiedNamespaceContext.AddFunctionImport("FindMyOwner", FullyQualifiedNamespaceFindMyOwnerFunction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("IsAddressGood", FullyQualifiedNamespaceIsAddressGoodFunction, null);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolPeople", FullyQualifiedNamespaceGetCoolPeopleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPerson", FullyQualifiedNamespaceGetCoolestPersonAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPersonWithStyle", FullyQualifiedNamespaceGetCoolestPersonWithStyleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetBestManager", FullyQualifiedNamespaceGetBestManagerAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddActionImport("GetNothing", FullyQualifiedNamespaceGetNothingAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumber", FullyQualifiedNamespaceGetSomeNumberAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddress", FullyQualifiedNamespaceGetSomeAddressAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumbers", FullyQualifiedNamespaceGetSomeNumbersAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddresses", FullyQualifiedNamespaceGetSomeAddressesAction);

            FullyQualifiedNamespaceContext.AddActionImport("ResetAllData", FullyQualifiedNamespaceResetAllDataAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction2);

            FullyQualifiedNamespaceContext.AddActionImport("MoveEveryone", FullyQualifiedNamespaceMoveEveryoneAction);

            #endregion

            try
            {
                // serialize edm
                XDocument document = new XDocument();
                IEnumerable<EdmError> errors;
                using (var writer = document.CreateWriter())
                {
                    EdmxWriter.TryWriteEdmx(model, writer, EdmxTarget.OData, out errors).Should().BeTrue();
                }

                string doc = document.ToString();

                // deserialize edm xml
                // TODO: remove the above model building codes.
                IEdmModel parsedModel;
                if (EdmxReader.TryParse(XmlReader.Create(new StringReader(HardCodedTestModelXml.MainModelXml)), (Uri uri) =>
                {
                    if (string.Equals(uri.AbsoluteUri, "http://submodel1/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml1));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel2/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml2));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel3/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml3));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel4/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml4));
                    }

                    throw new Exception("edmx:refernece must have a valid url." + uri.AbsoluteUri);
                }, out parsedModel, out errors))
                {
                   return parsedModel;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return null;
        }
Esempio n. 16
0
        public static IEdmModel TaupoDefaultModelEdm()
        {
            var model = new EdmModel();

            #region TaupoDefault Model code
            var phoneType = new EdmComplexType("NS1", "Phone");
            phoneType.AddStructuralProperty("PhoneNumber", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 16, isUnicode: false, isNullable: false));
            phoneType.AddStructuralProperty("Extension", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 16, isUnicode: false, isNullable: true));
            model.AddElement(phoneType);
            var phoneTypeReference = new EdmComplexTypeReference(phoneType, false);

            var contactDetailsType = new EdmComplexType("NS1", "ContactDetails");
            contactDetailsType.AddStructuralProperty("Email", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 32, isUnicode: false, isNullable: false));
            contactDetailsType.AddStructuralProperty("HomePhone", phoneTypeReference);
            contactDetailsType.AddStructuralProperty("WorkPhone", phoneTypeReference);
            contactDetailsType.AddStructuralProperty("MobilePhone", phoneTypeReference);
            model.AddElement(contactDetailsType);
            var contactDetailsTypeReference = new EdmComplexTypeReference(contactDetailsType, false);

            var concurrencyInfoType = new EdmComplexType("NS1", "ConcurrencyInfo");
            concurrencyInfoType.AddStructuralProperty("Token", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 20, isUnicode: false, isNullable: false), string.Empty, EdmConcurrencyMode.Fixed);
            concurrencyInfoType.AddStructuralProperty("QueriedDateTimeOffset", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(concurrencyInfoType);
            var concurrencyInfoTypeReference = new EdmComplexTypeReference(concurrencyInfoType, false);

            var auditInfoType = new EdmComplexType("NS1", "AuditInfo");
            auditInfoType.AddStructuralProperty("ModifiedDate", EdmPrimitiveTypeKind.DateTimeOffset);
            auditInfoType.AddStructuralProperty("ModifiedBy", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 50, isUnicode: false, isNullable: false));
            auditInfoType.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrencyInfoType, false));
            model.AddElement(auditInfoType);
            var auditInfoTypeReference = new EdmComplexTypeReference(auditInfoType, false);

            var dimensionsType = new EdmComplexType("NS1", "Dimensions");
            dimensionsType.AddStructuralProperty("Width", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            dimensionsType.AddStructuralProperty("Height", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            dimensionsType.AddStructuralProperty("Depth", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            model.AddElement(dimensionsType);
            var dimensionsTypeReference = new EdmComplexTypeReference(dimensionsType, false);

            var suspiciousActivityType = new EdmEntityType("NS1", "SuspiciousActivity");
            suspiciousActivityType.AddKeys(suspiciousActivityType.AddStructuralProperty("SuspiciousActivityId", EdmPrimitiveTypeKind.Int32, false));
            suspiciousActivityType.AddStructuralProperty("Activity", EdmPrimitiveTypeKind.String);
            model.AddElement(suspiciousActivityType);

            var messageType = new EdmEntityType("NS1", "Message");
            var fromUsername = messageType.AddStructuralProperty("FromUsername", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            messageType.AddKeys(messageType.AddStructuralProperty("MessageId", EdmPrimitiveTypeKind.Int32, false), fromUsername);
            var toUsername = messageType.AddStructuralProperty("ToUsername", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            messageType.AddStructuralProperty("Sent", EdmPrimitiveTypeKind.DateTimeOffset);
            messageType.AddStructuralProperty("Subject", EdmPrimitiveTypeKind.String);
            messageType.AddStructuralProperty("Body", EdmCoreModel.Instance.GetString(true));
            messageType.AddStructuralProperty("IsRead", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(messageType);

            var loginType = new EdmEntityType("NS1", "Login");
            loginType.AddKeys(loginType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false)));
            var loginCustomerIdProperty = loginType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
            model.AddElement(loginType);

            var loginSentMessages = new EdmNavigationPropertyInfo { Name = "SentMessages", Target = messageType, TargetMultiplicity = EdmMultiplicity.Many };
            var messageSender = new EdmNavigationPropertyInfo { Name = "Sender", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { fromUsername }, PrincipalProperties = loginType.Key() };
            loginType.AddBidirectionalNavigation(loginSentMessages, messageSender);
            var loginReceivedMessages = new EdmNavigationPropertyInfo { Name = "ReceivedMessages", Target = messageType, TargetMultiplicity = EdmMultiplicity.Many };
            var messageRecipient = new EdmNavigationPropertyInfo { Name = "Recipient", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { fromUsername }, PrincipalProperties = loginType.Key() };
            loginType.AddBidirectionalNavigation(loginReceivedMessages, messageRecipient);
            var loginSuspiciousActivity = new EdmNavigationPropertyInfo { Name = "SuspiciousActivity", Target = suspiciousActivityType, TargetMultiplicity = EdmMultiplicity.Many };
            loginType.AddUnidirectionalNavigation(loginSuspiciousActivity);

            var lastLoginType = new EdmEntityType("NS1", "LastLogin");
            var userNameProperty = lastLoginType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            lastLoginType.AddKeys(userNameProperty);
            lastLoginType.AddStructuralProperty("LoggedIn", EdmPrimitiveTypeKind.DateTimeOffset);
            lastLoginType.AddStructuralProperty("LoggedOut", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(lastLoginType);

            var loginLastLogin = new EdmNavigationPropertyInfo { Name = "LastLogin", Target = lastLoginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            var lastLoginLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { userNameProperty }, PrincipalProperties = loginType.Key() };
            lastLoginType.AddBidirectionalNavigation(lastLoginLogin, loginLastLogin);

            var orderType = new EdmEntityType("NS1", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false));
            var orderCustomerId = orderType.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            orderType.AddStructuralProperty("Concurrency", concurrencyInfoTypeReference);
            model.AddElement(orderType);

            var loginOrders = new EdmNavigationPropertyInfo { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many };
            var orderLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            orderType.AddBidirectionalNavigation(orderLogin, loginOrders);

            var customerInfoType = new EdmEntityType("NS1", "CustomerInfo");
            customerInfoType.AddKeys(customerInfoType.AddStructuralProperty("CustomerInfoId", EdmPrimitiveTypeKind.Int32, false));
            customerInfoType.AddStructuralProperty("Information", EdmPrimitiveTypeKind.String);
            model.AddElement(customerInfoType);

            var customerType = new EdmEntityType("NS1", "Customer");
            var customerIdProperty = customerType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
            customerType.AddKeys(customerIdProperty);
            customerType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isUnicode: false, isNullable: false));
            customerType.AddStructuralProperty("ContactInfo", contactDetailsTypeReference);
            model.AddElement(customerType);

            var customerOrders = new EdmNavigationPropertyInfo { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, };
            var orderCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customerType.Key() };
            customerType.AddBidirectionalNavigation(customerOrders, orderCustomer);
            var customerLogins = new EdmNavigationPropertyInfo { Name = "Logins", Target = loginType, TargetMultiplicity = EdmMultiplicity.Many, };
            var loginCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { loginCustomerIdProperty }, PrincipalProperties = customerType.Key() };
            customerType.AddBidirectionalNavigation(customerLogins, loginCustomer);
            var customerHusband = new EdmNavigationPropertyInfo { Name = "Husband", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            var customerWife = new EdmNavigationPropertyInfo { Name = "Wife", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            customerType.AddBidirectionalNavigation(customerHusband, customerWife);
            var customerInfo = new EdmNavigationPropertyInfo { Name = "CustomerInfo", Target = customerInfoType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            customerType.AddUnidirectionalNavigation(customerInfo);

            var productType = new EdmEntityType("NS1", "Product");
            productType.AddKeys(productType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false));
            productType.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: true, maxLength: 1000, isUnicode: false));
            productType.AddStructuralProperty("Dimensions", dimensionsTypeReference);
            productType.AddStructuralProperty("BaseConcurrency", EdmCoreModel.Instance.GetString(false), string.Empty, EdmConcurrencyMode.Fixed);
            productType.AddStructuralProperty("ComplexConcurrency", concurrencyInfoTypeReference);
            productType.AddStructuralProperty("NestedComplexConcurrency", auditInfoTypeReference);
            model.AddElement(productType);

            var barCodeType = new EdmEntityType("NS1", "Barcode");
            barCodeType.AddKeys(barCodeType.AddStructuralProperty("Code", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50)));
            var barCodeProductIdProperty = barCodeType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            barCodeType.AddStructuralProperty("Text", EdmPrimitiveTypeKind.String);
            model.AddElement(barCodeType);

            var productBarCodes = new EdmNavigationPropertyInfo { Name = "Barcodes", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.Many };
            var barCodeProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barCodeProductIdProperty }, PrincipalProperties = productType.Key() };
            barCodeType.AddBidirectionalNavigation(barCodeProduct, productBarCodes);

            var incorrectScanType = new EdmEntityType("NS1", "IncorrectScan");
            incorrectScanType.AddKeys(incorrectScanType.AddStructuralProperty("IncorrectScanId", EdmPrimitiveTypeKind.Int32, false));
            var expectedCodeProperty = incorrectScanType.AddStructuralProperty("ExpectedCode", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50));
            var actualCodeProperty = incorrectScanType.AddStructuralProperty("ActualCode", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: true, maxLength: 50));
            incorrectScanType.AddStructuralProperty("ScanDate", EdmPrimitiveTypeKind.DateTimeOffset);
            incorrectScanType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String);
            model.AddElement(incorrectScanType);

            var barCodeIncorrectScan = new EdmNavigationPropertyInfo { Name = "BadScans", Target = incorrectScanType, TargetMultiplicity = EdmMultiplicity.Many };
            var incorrectScanExpectedBarCode = new EdmNavigationPropertyInfo { Name = "ExpectedBarcode", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { expectedCodeProperty }, PrincipalProperties = barCodeType.Key() };
            incorrectScanType.AddBidirectionalNavigation(incorrectScanExpectedBarCode, barCodeIncorrectScan);
            var actualBarcode = new EdmNavigationPropertyInfo { Name = "ActualBarcode", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { actualCodeProperty }, PrincipalProperties = barCodeType.Key() };
            incorrectScanType.AddUnidirectionalNavigation(actualBarcode);

            var barCodeDetailType = new EdmEntityType("NS1", "BarcodeDetail");
            var codeProperty = barCodeDetailType.AddStructuralProperty("Code", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50));
            barCodeDetailType.AddKeys(codeProperty);
            barCodeDetailType.AddStructuralProperty("RegisteredTo", EdmPrimitiveTypeKind.String);
            model.AddElement(barCodeDetailType);

            var barCodeDetail = new EdmNavigationPropertyInfo { Name = "Detail", Target = barCodeDetailType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = barCodeType.Key(), PrincipalProperties = barCodeDetailType.Key() };
            barCodeType.AddUnidirectionalNavigation(barCodeDetail);

            var resolutionType = new EdmEntityType("NS1", "Resolution");
            resolutionType.AddKeys(resolutionType.AddStructuralProperty("ResolutionId", EdmPrimitiveTypeKind.Int32, false));
            resolutionType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String);
            model.AddElement(resolutionType);

            var complaintType = new EdmEntityType("NS1", "Complaint");
            complaintType.AddKeys(complaintType.AddStructuralProperty("ComplaintId", EdmPrimitiveTypeKind.Int32, false));
            var complaintCustomerId = complaintType.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            complaintType.AddStructuralProperty("Logged", EdmPrimitiveTypeKind.DateTimeOffset);
            complaintType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String);
            model.AddElement(complaintType);

            var complaintCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { complaintCustomerId }, PrincipalProperties = customerType.Key() };
            complaintType.AddUnidirectionalNavigation(complaintCustomer);
            var complaintResolution = new EdmNavigationPropertyInfo { Name = "Resolution", Target = resolutionType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            var resolutionComplaint = new EdmNavigationPropertyInfo { Name = "Complaint", Target = complaintType, TargetMultiplicity = EdmMultiplicity.One };
            complaintType.AddBidirectionalNavigation(complaintResolution, resolutionComplaint);

            var smartCardType = new EdmEntityType("NS1", "SmartCard");
            var smartCardUsername = smartCardType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            smartCardType.AddKeys(smartCardUsername);
            smartCardType.AddStructuralProperty("CardSerial", EdmPrimitiveTypeKind.String);
            smartCardType.AddStructuralProperty("Issued", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(smartCardType);

            var smartCardLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { smartCardUsername }, PrincipalProperties = loginType.Key() };
            smartCardType.AddUnidirectionalNavigation(smartCardLogin);
            var smartCardLastLogin = new EdmNavigationPropertyInfo { Name = "LastLogin", Target = lastLoginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            smartCardType.AddUnidirectionalNavigation(smartCardLastLogin);

            var rsaTokenType = new EdmEntityType("NS1", "RSAToken");
            rsaTokenType.AddKeys(rsaTokenType.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 20, isUnicode: false)));
            rsaTokenType.AddStructuralProperty("Issued", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(rsaTokenType);

            var rsaTokenLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One };
            rsaTokenType.AddUnidirectionalNavigation(rsaTokenLogin);

            var passwordResetType = new EdmEntityType("NS1", "PasswordReset");
            passwordResetType.AddKeys(passwordResetType.AddStructuralProperty("ResetNo", EdmPrimitiveTypeKind.Int32, false));
            var passwordResetUsername = passwordResetType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            passwordResetType.AddStructuralProperty("TempPassword", EdmPrimitiveTypeKind.String);
            passwordResetType.AddStructuralProperty("EmailedTo", EdmPrimitiveTypeKind.String);
            model.AddElement(passwordResetType);

            var passwordResetLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { passwordResetUsername }, PrincipalProperties = loginType.Key() };
            passwordResetType.AddUnidirectionalNavigation(passwordResetLogin);

            var pageViewType = new EdmEntityType("NS1", "PageView");
            pageViewType.AddKeys(pageViewType.AddStructuralProperty("PageViewId", EdmPrimitiveTypeKind.Int32, false));
            var pageViewUsername = pageViewType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
            pageViewType.AddStructuralProperty("Viewed", EdmPrimitiveTypeKind.DateTimeOffset);
            pageViewType.AddStructuralProperty("PageUrl", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 500, isUnicode: false));
            model.AddElement(pageViewType);

            var pageViewLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { pageViewUsername }, PrincipalProperties = loginType.Key() };
            pageViewType.AddUnidirectionalNavigation(pageViewLogin);

            var productPageViewType = new EdmEntityType("NS1", "ProductPageView", pageViewType);
            var productPageViewProductId = productPageViewType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            model.AddElement(productPageViewType);

            var productPageViewProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPageViewProductId }, PrincipalProperties = productType.Key() };
            productPageViewType.AddUnidirectionalNavigation(productPageViewProduct);

            var supplierType = new EdmEntityType("NS1", "Supplier");
            supplierType.AddKeys(supplierType.AddStructuralProperty("SupplierId", EdmPrimitiveTypeKind.Int32, false));
            supplierType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            model.AddElement(supplierType);

            var supplierProducts = new EdmNavigationPropertyInfo { Name = "Products", Target = productType, TargetMultiplicity = EdmMultiplicity.Many };
            var productSuppliers = new EdmNavigationPropertyInfo { Name = "Suppliers", Target = supplierType, TargetMultiplicity = EdmMultiplicity.Many };
            supplierType.AddBidirectionalNavigation(supplierProducts, productSuppliers);

            var supplierLogoType = new EdmEntityType("NS1", "SupplierLogo");
            var supplierLogoSupplierId = supplierLogoType.AddStructuralProperty("SupplierId", EdmPrimitiveTypeKind.Int32, false);
            supplierLogoType.AddKeys(supplierLogoSupplierId);
            supplierLogoType.AddStructuralProperty("Logo", EdmCoreModel.Instance.GetBinary(isNullable: false, isUnbounded: false, maxLength: 500));
            model.AddElement(supplierLogoType);

            var supplierSupplierLogo = new EdmNavigationPropertyInfo { Name = "Logo", Target = supplierLogoType, TargetMultiplicity = EdmMultiplicity.One, PrincipalProperties = new[] { supplierLogoSupplierId }, DependentProperties = supplierType.Key() };
            supplierType.AddUnidirectionalNavigation(supplierSupplierLogo);

            var supplierInfoType = new EdmEntityType("NS1", "SupplierInfo");
            supplierInfoType.AddKeys(supplierInfoType.AddStructuralProperty("SupplierInfoId", EdmPrimitiveTypeKind.Int32, false));
            supplierInfoType.AddStructuralProperty("Information", EdmPrimitiveTypeKind.String);
            model.AddElement(supplierInfoType);

            var supplierInfoSupplier = new EdmNavigationPropertyInfo { Name = "Supplier", Target = supplierType, TargetMultiplicity = EdmMultiplicity.One, OnDelete = EdmOnDeleteAction.Cascade };
            supplierInfoType.AddUnidirectionalNavigation(supplierInfoSupplier);

            var orderNoteType = new EdmEntityType("NS1", "OrderNote");
            orderNoteType.AddKeys(orderNoteType.AddStructuralProperty("NoteId", EdmPrimitiveTypeKind.Int32, false));
            orderNoteType.AddStructuralProperty("Note", EdmPrimitiveTypeKind.String);
            model.AddElement(orderNoteType);

            var orderNoteOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One };
            var orderOrderNotes = new EdmNavigationPropertyInfo { Name = "Notes", Target = orderNoteType, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade };
            orderNoteType.AddBidirectionalNavigation(orderNoteOrder, orderOrderNotes);

            var orderQualityCheckType = new EdmEntityType("NS1", "OrderQualityCheck");
            var orderQualityCheckOrderId = orderQualityCheckType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false);
            orderQualityCheckType.AddKeys(orderQualityCheckOrderId);
            orderQualityCheckType.AddStructuralProperty("CheckedBy", EdmPrimitiveTypeKind.String);
            orderQualityCheckType.AddStructuralProperty("CheckedDateTime", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(orderQualityCheckType);

            var orderQualityCheckOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderQualityCheckOrderId }, PrincipalProperties = orderType.Key() };
            orderQualityCheckType.AddUnidirectionalNavigation(orderQualityCheckOrder);

            var orderLineType = new EdmEntityType("NS1", "OrderLine");
            var orderLineOrderId = orderLineType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false);
            var orderLineProductId = orderLineType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            orderLineType.AddKeys(orderLineOrderId, orderLineProductId);
            orderLineType.AddStructuralProperty("Quantity", EdmPrimitiveTypeKind.Int32);
            orderLineType.AddStructuralProperty("ConcurrencyToken", EdmCoreModel.Instance.GetString(false), string.Empty, EdmConcurrencyMode.Fixed);
            model.AddElement(orderLineType);

            var orderLineOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineOrderId }, PrincipalProperties = orderType.Key() };
            var orderOrderLine = new EdmNavigationPropertyInfo { Name = "OrderLines", Target = orderLineType, TargetMultiplicity = EdmMultiplicity.Many };
            orderLineType.AddBidirectionalNavigation(orderLineOrder, orderOrderLine);

            var orderLineProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineProductId }, PrincipalProperties = productType.Key() };
            orderLineType.AddUnidirectionalNavigation(orderLineProduct);

            var backOrderLineType = new EdmEntityType("NS1", "BackOrderLine", orderLineType);
            backOrderLineType.AddStructuralProperty("ETA", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(backOrderLineType);

            var backOrderLineSupplier = new EdmNavigationPropertyInfo { Name = "Supplier", Target = supplierType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            var supplierBackOrderLines = new EdmNavigationPropertyInfo { Name = "BackOrderLines", Target = backOrderLineType, TargetMultiplicity = EdmMultiplicity.Many };
            backOrderLineType.AddBidirectionalNavigation(backOrderLineSupplier, supplierBackOrderLines);

            var backOrderLine2Type = new EdmEntityType("NS1", "BackOrderLine2", backOrderLineType);
            model.AddElement(backOrderLine2Type);

            var discontinuedProductType = new EdmEntityType("NS1", "DiscontinuedProduct", productType);
            discontinuedProductType.AddStructuralProperty("Discontinued", EdmPrimitiveTypeKind.DateTimeOffset);
            var replacementProductId = discontinuedProductType.AddStructuralProperty("ReplacementProductId", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(discontinuedProductType);

            var discontinuedProductReplacement = new EdmNavigationPropertyInfo { Name = "ReplacedBy", Target = productType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { replacementProductId }, PrincipalProperties = productType.Key() };
            var productReplaces = new EdmNavigationPropertyInfo { Name = "Replaces", Target = discontinuedProductType, TargetMultiplicity = EdmMultiplicity.Many, };
            discontinuedProductType.AddBidirectionalNavigation(discontinuedProductReplacement, productReplaces);

            var productDetailType = new EdmEntityType("NS1", "ProductDetail");
            var productDetailProductId = productDetailType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            productDetailType.AddKeys(productDetailProductId);
            productDetailType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String);
            model.AddElement(productDetailType);

            var productDetailProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productDetailProductId }, PrincipalProperties = productType.Key() };
            var productProductDetail = new EdmNavigationPropertyInfo { Name = "Detail", Target = productDetailType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
            productDetailType.AddBidirectionalNavigation(productDetailProduct, productProductDetail);

            var productReviewType = new EdmEntityType("NS1", "ProductReview");
            var productReviewProductId = productReviewType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            productReviewType.AddKeys(productReviewProductId, productReviewType.AddStructuralProperty("ReviewId", EdmPrimitiveTypeKind.Int32, false));
            productReviewType.AddStructuralProperty("Review", EdmPrimitiveTypeKind.String);
            model.AddElement(productReviewType);

            var productReviewProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productReviewProductId }, PrincipalProperties = productType.Key() };
            var productProductReviews = new EdmNavigationPropertyInfo { Name = "Reviews", Target = productReviewType, TargetMultiplicity = EdmMultiplicity.Many };
            productReviewType.AddBidirectionalNavigation(productReviewProduct, productProductReviews);

            var productPhotoType = new EdmEntityType("NS1", "ProductPhoto");
            var productPhotoProductId = productPhotoType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false);
            productPhotoType.AddKeys(productPhotoProductId, productPhotoType.AddStructuralProperty("PhotoId", EdmPrimitiveTypeKind.Int32, false));
            productPhotoType.AddStructuralProperty("Photo", EdmPrimitiveTypeKind.Binary);
            model.AddElement(productPhotoType);

            var productProductPhotos = new EdmNavigationPropertyInfo { Name = "Photos", Target = productPhotoType, TargetMultiplicity = EdmMultiplicity.Many };
            var productPhotoProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPhotoProductId }, PrincipalProperties = productType.Key() };
            productType.AddBidirectionalNavigation(productProductPhotos, productPhotoProduct);

            var productWebFeatureType = new EdmEntityType("NS1", "ProductWebFeature");
            productWebFeatureType.AddKeys(productWebFeatureType.AddStructuralProperty("FeatureId", EdmPrimitiveTypeKind.Int32, false));
            var productWebFeatureProductId = productWebFeatureType.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(true));
            var productWebFeaturePhotoId = productWebFeatureType.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(true));
            var productWebFeatureReviewId = productWebFeatureType.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(true));
            productWebFeatureType.AddStructuralProperty("Heading", EdmPrimitiveTypeKind.String);
            model.AddElement(productWebFeatureType);

            var productReviewWebFeatures = new EdmNavigationPropertyInfo { Name = "Features", Target = productWebFeatureType, TargetMultiplicity = EdmMultiplicity.Many };
            var productWebFeatureReview = new EdmNavigationPropertyInfo { Name = "Review", Target = productReviewType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeatureReviewId, productWebFeatureProductId }, PrincipalProperties = productReviewType.Key() };
            productWebFeatureType.AddBidirectionalNavigation(productWebFeatureReview, productReviewWebFeatures);

            var productPhotoWebFeatures = new EdmNavigationPropertyInfo { Name = "Features", Target = productWebFeatureType, TargetMultiplicity = EdmMultiplicity.Many };
            var productWebFeaturePhoto = new EdmNavigationPropertyInfo { Name = "Photo", Target = productPhotoType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeaturePhotoId, productWebFeatureProductId }, PrincipalProperties = productPhotoType.Key() };
            productWebFeatureType.AddBidirectionalNavigation(productWebFeaturePhoto, productPhotoWebFeatures);

            var computerType = new EdmEntityType("NS1", "Computer");
            computerType.AddKeys(computerType.AddStructuralProperty("ComputerId", EdmPrimitiveTypeKind.Int32, false));
            computerType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            model.AddElement(computerType);

            var computerDetailType = new EdmEntityType("NS1", "ComputerDetail");
            computerDetailType.AddKeys(computerDetailType.AddStructuralProperty("ComputerDetailId", EdmPrimitiveTypeKind.Int32, false));
            computerDetailType.AddStructuralProperty("Model", EdmPrimitiveTypeKind.String);
            computerDetailType.AddStructuralProperty("Serial", EdmPrimitiveTypeKind.String);
            computerDetailType.AddStructuralProperty("Specifications", EdmPrimitiveTypeKind.String);
            computerDetailType.AddStructuralProperty("PurchaseDate", EdmPrimitiveTypeKind.DateTimeOffset);
            computerDetailType.AddStructuralProperty("Dimensions", dimensionsTypeReference);
            model.AddElement(computerDetailType);

            var computerDetailComputer = new EdmNavigationPropertyInfo { Name = "Computer", Target = computerType, TargetMultiplicity = EdmMultiplicity.One };
            var computerComputerDetail = new EdmNavigationPropertyInfo { Name = "ComputerDetail", Target = computerDetailType, TargetMultiplicity = EdmMultiplicity.One };
            computerType.AddBidirectionalNavigation(computerComputerDetail, computerDetailComputer);

            var driverType = new EdmEntityType("NS1", "Driver");
            driverType.AddKeys(driverType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isNullable: false, isUnicode: false)));
            driverType.AddStructuralProperty("BirthDate", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(driverType);

            var licenseType = new EdmEntityType("NS1", "License");
            var licenseDriverName = licenseType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isNullable: false, isUnicode: false));
            licenseType.AddKeys(licenseDriverName);
            licenseType.AddStructuralProperty("LicenseNumber", EdmPrimitiveTypeKind.String);
            licenseType.AddStructuralProperty("LicenseClass", EdmPrimitiveTypeKind.String);
            licenseType.AddStructuralProperty("Restrictions", EdmPrimitiveTypeKind.String);
            licenseType.AddStructuralProperty("ExpirationDate", EdmPrimitiveTypeKind.DateTimeOffset);
            model.AddElement(licenseType);

            var driverLicense = new EdmNavigationPropertyInfo { Name = "License", Target = licenseType, TargetMultiplicity = EdmMultiplicity.One, };
            var licenseDriver = new EdmNavigationPropertyInfo { Name = "Driver", Target = driverType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { licenseDriverName }, PrincipalProperties = driverType.Key() };
            licenseType.AddBidirectionalNavigation(licenseDriver, driverLicense);

            #endregion

            model.AddDefaultContainerFixup("NS1");
            return model;
        }
        public static IEdmModel AssociationNameSimpleIdentifier()
        {
            EdmModel model = new EdmModel();
            EdmEntityType t1 = new EdmEntityType("Bunk", "T1");
            EdmEntityType t2 = new EdmEntityType("Bunk", "T2");
            model.AddElement(t1);
            model.AddElement(t2);

            EdmStructuralProperty f11 = t1.AddStructuralProperty("F11", EdmCoreModel.Instance.GetInt16(false));
            EdmStructuralProperty f21 = t2.AddStructuralProperty("F21", EdmCoreModel.Instance.GetString(false));

            t1.AddKeys(f11);
            t2.AddKeys(f21);

            EdmNavigationProperty p101 = t1.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "P1", Target = t2, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "P1_Partner", TargetMultiplicity = EdmMultiplicity.Many });
            EdmNavigationProperty p102 = t1.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "P2", Target = t2, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "P2_Partner", TargetMultiplicity = EdmMultiplicity.Many });
            EdmNavigationProperty p201 = t2.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "P3", Target = t1, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "P3_Partner", TargetMultiplicity = EdmMultiplicity.Many });

            return model;
        }