public EntityModelSchema GenerateModel()
        {
            var model = new EntityModelSchema()
            {
                new EntityType("Store")
                {
                    IsAbstract = true,
                    Properties =
                    {
                        new MemberProperty("StoreId",          DataTypes.Integer)
                        {
                            IsPrimaryKey = true
                        },
                        new MemberProperty("Name",             DataTypes.String.Nullable(false)),
                        new MemberProperty("Location",         EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("ConcurrencyToken", DataTypes.String.Nullable(true).WithMaxLength(4))
                        {
                            Annotations = { new ConcurrencyTokenAnnotation() }
                        },
                    },
                    NavigationProperties =
                    {
                        new NavigationProperty("FavoriteOf", "Person_FavoriteStore", "Store", "Person"),
                    }
                },
                new EntityType("CoffeeShop")
                {
                    BaseType   = "Store",
                    Properties =
                    {
                        new MemberProperty("Entrance",      EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("EmergencyExit", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    },
                    NavigationProperties =
                    {
                        new NavigationProperty("Flavors", "CoffeeShop_Flavors", "CoffeeShop", "Flavor"),
                    }
                },
                new EntityType("Pizzeria")
                {
                    BaseType   = "Store",
                    Properties =
                    {
                        new MemberProperty("DeliveryAreas",  EdmDataTypes.GeographyMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("DeliveryRoutes", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))),
                        new MemberProperty("ReceptionDesk",  EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("Oven",           EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    },
                    NavigationProperties =
                    {
                        new NavigationProperty("Logo", "Pizzeria_Logo", "Pizzeria", "Logo"),
                    }
                },
                new EntityType("CoffeeFlavor")
                {
                    new MemberProperty("Name", DataTypes.String.Nullable(false))
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("Description", DataTypes.String.Nullable(true)),
                    new MemberProperty("ConcurrencyToken", DataTypes.String.Nullable(true).WithMaxLength(4))
                    {
                        Annotations = { new ConcurrencyTokenAnnotation() }
                    },
                    new MemberProperty("Grown", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))),
                    new NavigationProperty("StoresSoldAt", "CoffeeShop_Flavors", "Flavor", "CoffeeShop"),
                    new NavigationProperty("FavoriteOf", "Person_FavoriteFlavor", "Flavor", "Person"),
                },
                new EntityType("Person")
                {
                    new MemberProperty("FirstName", DataTypes.String.Nullable(false))
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("LastName", DataTypes.String.Nullable(false))
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("CurrentAddress", DataTypes.ComplexType.WithName("Address")),
                    new MemberProperty("PastAddresses", DataTypes.CollectionOfComplex("Address")),
                    new MemberProperty("RecentLocations", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))),
                    new NavigationProperty("FavoriteStore", "Person_FavoriteStore", "Person", "Store"),
                    new NavigationProperty("FavoriteCoffeeFlavor", "Person_FavoriteFlavor", "Person", "Flavor"),
                    new NavigationProperty("Photos", "Person_Photos", "Person", "Photo"),
                    new NavigationProperty("FavoritePhoto", "Person_FavoritePhoto", "Person", "Photo"),
                },
                new EntityType("Photo")
                {
                    new HasStreamAnnotation(),
                    new MemberProperty("StoreId", DataTypes.Integer)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("WhereTaken", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new NavigationProperty("Owner", "Person_Photos", "Photo", "Person"),
                    new NavigationProperty("Pizzeria", "Pizzeria_Logo", "Logo", "Pizzeria"),
                },

                // TODO: Fix streams on derived types for spatial client tests
                ////new EntityType("PhotoWithThumbnail")
                ////{
                ////    BaseType = "Photo",
                ////    Properties =
                ////    {
                ////        new MemberProperty("Thumbnail", DataTypes.Stream),
                ////    },
                ////},
                new EntityType("HikingTrail")
                {
                    new MemberProperty("Name", DataTypes.String)
                    {
                        IsPrimaryKey = true
                    },
                },
                new EntityType("HikingTrailWithCoordinates")
                {
                    BaseType   = "HikingTrail",
                    Properties =
                    {
                        new MemberProperty("MainPath",       EdmDataTypes.GeographyLineString.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("AlternatePaths", EdmDataTypes.GeographyMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                        new MemberProperty("TrailHead",      EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    },
                },
                new EntityType("AllSpatialTypes")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },

                    new MemberProperty("Geog", EdmDataTypes.Geography.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPoint", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogLine", EdmDataTypes.GeographyLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPolygon", EdmDataTypes.GeographyPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogCollection", EdmDataTypes.GeographyCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPoint", EdmDataTypes.GeographyMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiLine", EdmDataTypes.GeographyMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPolygon", EdmDataTypes.GeographyMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Geom", EdmDataTypes.Geometry.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPoint", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomLine", EdmDataTypes.GeometryLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPolygon", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomCollection", EdmDataTypes.GeometryCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPoint", EdmDataTypes.GeometryMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiLine", EdmDataTypes.GeometryMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPolygon", EdmDataTypes.GeometryMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Complex", DataTypes.ComplexType.WithName("AllSpatialTypesComplex")),
                },
                new EntityType("AllSpatialCollectionTypes")
                {
                    IsAbstract = true,
                    Properties =
                    {
                        new MemberProperty("Id", EdmDataTypes.Int32)
                        {
                            IsPrimaryKey = true
                        },
                    }
                },
                new EntityType("AllSpatialCollectionTypes_Simple")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyGeogPoint",   DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeogLine",    DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeogPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),

                        new MemberProperty("ManyGeomPoint",   DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomLine",    DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_Intermediate")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyGeog",           DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Geography.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeogCollection", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyCollection.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),

                        new MemberProperty("ManyGeom",           DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Geometry.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomCollection", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryCollection.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_MultiPoint")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyGeogMultiPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomMultiPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_MultiLine")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyGeogMultiLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomMultiLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_MultiPolygon")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyGeogMultiPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                        new MemberProperty("ManyGeomMultiPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_Complex1")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyComplex", DataTypes.CollectionOfComplex("AllSpatialTypesComplex")).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    },
                },
                new EntityType("AllSpatialCollectionTypes_Complex2")
                {
                    BaseType   = "AllSpatialCollectionTypes",
                    Properties =
                    {
                        new MemberProperty("ManyCollectionComplex", DataTypes.ComplexType.WithName("AllSpatialCollectionTypesComplex")),
                    },
                },
                new EntityType("ApplicationWindow")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("Origin", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("Border", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("MultiTouchPoints", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))),
                    new NavigationProperty("Controls", "Window_Controls", "Window", "Control"),
                },
                new EntityType("ApplicationControl")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("Origin", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("Border", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new NavigationProperty("Window", "Window_Controls", "Control", "Window"),
                },
                new EntityType("Shape")
                {
                    IsAbstract = true,
                    Properties =
                    {
                        new MemberProperty("Id", EdmDataTypes.Int32)
                        {
                            IsPrimaryKey = true
                        },
                    },
                },
                new EntityType("Point")
                {
                    BaseType   = "Shape",
                    Properties =
                    {
                        new MemberProperty("PointValue", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    }
                },
                new EntityType("Line")
                {
                    BaseType   = "Shape",
                    Properties =
                    {
                        new MemberProperty("LineValue", EdmDataTypes.GeometryLineString.WithSrid(SpatialConstants.VariableSrid)),
                    }
                },
                new EntityType("Polygon")
                {
                    BaseType   = "Shape",
                    Properties =
                    {
                        new MemberProperty("Value", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    }
                },
                new ComplexType("Address")
                {
                    new MemberProperty("Location", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                },
                new ComplexType("AllSpatialTypesComplex")
                {
                    new MemberProperty("Geog", EdmDataTypes.Geography.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPoint", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogLine", EdmDataTypes.GeographyLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPolygon", EdmDataTypes.GeographyPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogCollection", EdmDataTypes.GeographyCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPoint", EdmDataTypes.GeographyMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiLine", EdmDataTypes.GeographyMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPolygon", EdmDataTypes.GeographyMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Geom", EdmDataTypes.Geometry.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPoint", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomLine", EdmDataTypes.GeometryLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPolygon", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomCollection", EdmDataTypes.GeometryCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPoint", EdmDataTypes.GeometryMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiLine", EdmDataTypes.GeometryMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPolygon", EdmDataTypes.GeometryMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),
                },
                new ComplexType("AllSpatialCollectionTypesComplex")
                {
                    new MemberProperty("ManyGeog", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Geography.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogCollection", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyCollection.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogMultiPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogMultiLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeogMultiPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeographyMultiPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),

                    new MemberProperty("ManyGeom", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Geometry.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomCollection", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryCollection.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomMultiPoint", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiPoint.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomMultiLine", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiLineString.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                    new MemberProperty("ManyGeomMultiPolygon", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.GeometryMultiPolygon.NotNullable().WithSrid(SpatialConstants.VariableSrid))).WithDataGenerationHints(DataGenerationHints.MaxCount(2)),
                },
                new AssociationType("CoffeeShop_Flavors")
                {
                    new AssociationEnd("CoffeeShop", "CoffeeShop", EndMultiplicity.Many),
                    new AssociationEnd("Flavor", "CoffeeFlavor", EndMultiplicity.Many),
                },
                new AssociationType("Person_FavoriteStore")
                {
                    new AssociationEnd("Person", "Person", EndMultiplicity.Many),
                    new AssociationEnd("Store", "Store", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Pizzeria_Logo")
                {
                    new AssociationEnd("Logo", "Photo", EndMultiplicity.One),
                    new AssociationEnd("Pizzeria", "Pizzeria", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Person_FavoriteFlavor")
                {
                    new AssociationEnd("Person", "Person", EndMultiplicity.Many),
                    new AssociationEnd("Flavor", "CoffeeFlavor", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Person_Photos")
                {
                    new AssociationEnd("Person", "Person", EndMultiplicity.ZeroOne),
                    new AssociationEnd("Photo", "Photo", EndMultiplicity.Many),
                },
                new AssociationType("Person_FavoritePhoto")
                {
                    new AssociationEnd("Person", "Person", EndMultiplicity.Many),
                    new AssociationEnd("Photo", "Photo", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Window_Controls")
                {
                    new AssociationEnd("Window", "ApplicationWindow", EndMultiplicity.ZeroOne),
                    new AssociationEnd("Control", "ApplicationControl", EndMultiplicity.Many),
                },
                new EntityContainer("SpatialContainer")
                {
                    new DataServiceConfigurationAnnotation()
                    {
                        UseVerboseErrors = true,
                    },
                    new DataServiceBehaviorAnnotation()
                    {
                        AcceptSpatialLiteralsInQuery = true,
                        MaxProtocolVersion           = DataServiceProtocolVersion.V4,
                    },
                    new EntitySet("Stores", "Store")
                    {
                        new PageSizeAnnotation()
                        {
                            PageSize = 3
                        },
                    },
                    new EntitySet("Flavors", "CoffeeFlavor"),
                    new EntitySet("People", "Person"),
                    new EntitySet("Photos", "Photo")
                    {
                        new PageSizeAnnotation()
                        {
                            PageSize = 5
                        },
                    },
                    new EntitySet("Trails", "HikingTrail"),
                    new EntitySet("AllTypesSet", "AllSpatialTypes")
                    {
                        new PageSizeAnnotation()
                        {
                            PageSize = 2
                        },
                    },
                    new EntitySet("AllCollectionTypesSet", "AllSpatialCollectionTypes"),
                    new EntitySet("ApplicationWindows", "ApplicationWindow")
                    {
                        new PageSizeAnnotation()
                        {
                            PageSize = 4
                        },
                    },
                    new EntitySet("ApplicationControls", "ApplicationControl"),
                    new EntitySet("Shapes", "Shape"),
                    new AssociationSet("Stores_Flavors", "CoffeeShop_Flavors")
                    {
                        new AssociationSetEnd("CoffeeShop", "Stores"),
                        new AssociationSetEnd("Flavor", "Flavors"),
                    },
                    new AssociationSet("People_Stores", "Person_FavoriteStore")
                    {
                        new AssociationSetEnd("Person", "People"),
                        new AssociationSetEnd("Store", "Stores"),
                    },
                    new AssociationSet("People_Flavors", "Person_FavoriteFlavor")
                    {
                        new AssociationSetEnd("Person", "People"),
                        new AssociationSetEnd("Flavor", "Flavors"),
                    },
                    new AssociationSet("People_Photos", "Person_Photos")
                    {
                        new AssociationSetEnd("Person", "People"),
                        new AssociationSetEnd("Photo", "Photos"),
                    },
                    new AssociationSet("People_FavoritePhotos", "Person_FavoritePhoto")
                    {
                        new AssociationSetEnd("Person", "People"),
                        new AssociationSetEnd("Photo", "Photos"),
                    },
                    new AssociationSet("Pizzeria_Logo", "Pizzeria_Logo")
                    {
                        new AssociationSetEnd("Logo", "Photos"),
                        new AssociationSetEnd("Pizzeria", "Stores"),
                    },
                    new AssociationSet("Windows_Controls", "Window_Controls")
                    {
                        new AssociationSetEnd("Window", "ApplicationWindows"),
                        new AssociationSetEnd("Control", "ApplicationControls"),
                    },
                }
            };

            new ResolveReferencesFixup().Fixup(model);
            new ApplyDefaultNamespaceFixup("Spatial").Fixup(model);

            return(model);
        }
Exemplo n.º 2
0
        public EntityModelSchema GenerateModel()
        {
            this.useDataTypes = new Dictionary <DataType, bool>();

            var model = new EntityModelSchema()
            {
                new EntityType("Movie")
                {
                    Annotations =
                    {
                        new HasStreamAnnotation(),
                    },
                    Properties =
                    {
                        new MemberProperty("Id",               EdmDataTypes.Int32)
                        {
                            IsPrimaryKey = true
                        },
                        new MemberProperty("Name",             EdmDataTypes.String()),
                        new MemberProperty("LengthInMinutes",  EdmDataTypes.Int32)
                        {
                            Annotations = { new ConcurrencyTokenAnnotation() }
                        },
                        new MemberProperty("ReleaseYear",      EdmDataTypes.DateTime()),
                        new MemberProperty("Trailer",          EdmDataTypes.Stream),
                        new MemberProperty("FullMovie",        EdmDataTypes.Stream),
                        new MemberProperty("IsAwardWinner",    EdmDataTypes.Boolean),
                        new MemberProperty("AddToQueueValue",  EdmDataTypes.Boolean),
                        new MemberProperty("AddToQueueValue2", EdmDataTypes.Boolean),
                        new MemberProperty("MovieHomePage",    EdmDataTypes.String()).WithDataGenerationHints(DataGenerationHints.NoNulls,DataGenerationHints.AnsiString,  DataGenerationHints.MinLength(10)),
                        new MemberProperty("Description",      EdmDataTypes.String()).WithDataGenerationHints(DataGenerationHints.NoNulls,DataGenerationHints.AnsiString,  DataGenerationHints.MinLength(10)),
                    },

                    NavigationProperties =
                    {
                        new NavigationProperty("MovieRatings", "MovieRating_Movie", "Movie",  "MovieRating"),
                        new NavigationProperty("Actors",       "Movies_Actors",     "Movies", "Actors"),
                    }
                },
                new ComplexType("Phone")
                {
                    new MemberProperty("PhoneNumber", EdmDataTypes.String()),
                    new MemberProperty("Extension", EdmDataTypes.String().Nullable(true)),
                },
                new ComplexType("ContactDetails")
                {
                    new MemberProperty("PhoneMultiValue", DataTypes.CollectionOfComplex("Phone")),
                },
                new ComplexType("Rating")
                {
                    new MemberProperty("Comments", EdmDataTypes.String()),
                    new MemberProperty("FiveStarRating", EdmDataTypes.Byte),
                    new MemberProperty("Tags", DataTypes.CollectionType.WithElementDataType(DataTypes.String)),
                },
                new ComplexType("AllSpatialTypesComplex")
                {
                    new MemberProperty("Geog", EdmDataTypes.Geography.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPoint", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogLine", EdmDataTypes.GeographyLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPolygon", EdmDataTypes.GeographyPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogCollection", EdmDataTypes.GeographyCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPoint", EdmDataTypes.GeographyMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiLine", EdmDataTypes.GeographyMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPolygon", EdmDataTypes.GeographyMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Geom", EdmDataTypes.Geometry.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPoint", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomLine", EdmDataTypes.GeometryLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPolygon", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomCollection", EdmDataTypes.GeometryCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPoint", EdmDataTypes.GeometryMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiLine", EdmDataTypes.GeometryMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPolygon", EdmDataTypes.GeometryMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),
                },
                new EntityType("MovieRating")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("Rating", DataTypes.ComplexType.WithDefinition("Rating")),
                    new MemberProperty("IsCreatedByCustomer", EdmDataTypes.Boolean),
                    new NavigationProperty("Movie", "MovieRating_Movie", "MovieRating", "Movie"),
                },
                new EntityType("Actor")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("FirstName", EdmDataTypes.String()),
                    new MemberProperty("LastName", EdmDataTypes.String()),
                    new MemberProperty("Age", EdmDataTypes.Int32),
                    new MemberProperty("IsAwardWinner", EdmDataTypes.Boolean),
                    new MemberProperty("ContactDetails", DataTypes.ComplexType.WithName("ContactDetails")),
                    new MemberProperty("PrimaryPhoneNumber", DataTypes.ComplexType.WithName("Phone")),
                    new MemberProperty("AdditionalPhoneNumbers", DataTypes.CollectionOfComplex("Phone")),
                    new MemberProperty("AlternativeNames", DataTypes.CollectionType.WithElementDataType(DataTypes.String)),
                    new NavigationProperty("Movies", "Movies_Actors", "Actors", "Movies"),
                },
                new EntityType("Producer")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("FirstName", EdmDataTypes.String()),
                    new MemberProperty("LastName", EdmDataTypes.String()),
                    new MemberProperty("Toggle", EdmDataTypes.Boolean),
                },
                new EntityType("ExecutiveProducer")
                {
                    BaseType = "Producer"
                },
                new EntityType("ActorMovieRating")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("IsStar", EdmDataTypes.Boolean),
                    new MemberProperty("Rating", DataTypes.ComplexType.WithDefinition("Rating")),
                    new NavigationProperty("Actor", "ActorMovieRating_Actor", "ActorMovieRating", "Actor"),
                    new NavigationProperty("Movie", "ActorMovieRating_Movie", "ActorMovieRating", "Movie"),
                },
                new EntityType("AllTypes")
                {
                    // This EntityType contains only primitive properties
                    new MemberProperty("Id", DataTypes.Integer)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("ToggleProperty", EdmDataTypes.Boolean),
                    new MemberProperty("BooleanProperty", EdmDataTypes.Boolean),
                    new MemberProperty("StringProperty", EdmDataTypes.String()).WithDataGenerationHints(DataGenerationHints.NoNulls),
                    new MemberProperty("ByteProperty", EdmDataTypes.Byte),
                    new MemberProperty("DateTimeProperty", EdmDataTypes.DateTime()),
                    new MemberProperty("DecimalProperty", EdmDataTypes.Decimal()),
                    new MemberProperty("DoubleProperty", EdmDataTypes.Double),
                    new MemberProperty("GuidProperty", EdmDataTypes.Guid),
                    new MemberProperty("Int16Property", EdmDataTypes.Int16),
                    new MemberProperty("Int32Property", EdmDataTypes.Int32),
                    new MemberProperty("Int64Property", EdmDataTypes.Int64),
                    new MemberProperty("SingleProperty", EdmDataTypes.Single),
                    new MemberProperty("BinaryProperty", EdmDataTypes.Binary()),
                    new MemberProperty("DateTimeOffsetProperty", EdmDataTypes.DateTimeOffset().NotNullable()),
                    new MemberProperty("TimeSpanProperty", EdmDataTypes.Time().NotNullable()),
                    new MemberProperty("NullableDateTimeOffsetProperty", EdmDataTypes.DateTimeOffset().Nullable()),
                    new MemberProperty("NullableTimeSpanProperty", EdmDataTypes.Time().Nullable()),

                    new MemberProperty("ByteCollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Byte)).WithDataGenerationHints(DataGenerationHints.NoNulls, DataGenerationHints.MaxCount(0)),
                    new MemberProperty("DoubleCollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Double)).WithDataGenerationHints(DataGenerationHints.NoNulls),
                    new MemberProperty("Int32CollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Int32)).WithDataGenerationHints(DataGenerationHints.NoNulls),
                    new MemberProperty("StringCollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.String())).WithDataGenerationHints(DataGenerationHints.NoNulls),
                    new MemberProperty("DateTimeOffsetCollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.DateTimeOffset())).WithDataGenerationHints(DataGenerationHints.NoNulls),
                    new MemberProperty("TimeSpanCollectionProperty", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.Time())).WithDataGenerationHints(DataGenerationHints.NoNulls),

                    //// TODO: add the following
                    ////new MemberProperty("NullStringProperty", DataTypes.String).WithDataGenerationHints(DataGenerationHints.AllNulls),
                    ////new MemberProperty("NullBinaryProperty", DataTypes.Binary.WithMaxLength(500)).WithDataGenerationHints(DataGenerationHints.AllNulls),
                },
                new EntityType("AllSpatialTypes")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("ToggleProperty", EdmDataTypes.Boolean),
                    new MemberProperty("Int32Property", EdmDataTypes.Int32),

                    new MemberProperty("Geog", EdmDataTypes.Geography.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPoint", EdmDataTypes.GeographyPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogLine", EdmDataTypes.GeographyLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogPolygon", EdmDataTypes.GeographyPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogCollection", EdmDataTypes.GeographyCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPoint", EdmDataTypes.GeographyMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiLine", EdmDataTypes.GeographyMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeogMultiPolygon", EdmDataTypes.GeographyMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Geom", EdmDataTypes.Geometry.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPoint", EdmDataTypes.GeometryPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomLine", EdmDataTypes.GeometryLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomPolygon", EdmDataTypes.GeometryPolygon.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomCollection", EdmDataTypes.GeometryCollection.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPoint", EdmDataTypes.GeometryMultiPoint.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiLine", EdmDataTypes.GeometryMultiLineString.WithSrid(SpatialConstants.VariableSrid)),
                    new MemberProperty("GeomMultiPolygon", EdmDataTypes.GeometryMultiPolygon.WithSrid(SpatialConstants.VariableSrid)),

                    new MemberProperty("Complex", DataTypes.ComplexType.WithName("AllSpatialTypesComplex")),
                },
                new EntityType("DVDCustomer")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("Name", EdmDataTypes.String()),
                    new MemberProperty("EMail", EdmDataTypes.String()),
                    new MemberProperty("Visa", EdmDataTypes.Int32),
                    new MemberProperty("BalancePaid", EdmDataTypes.Boolean),
                    new NavigationProperty("DVDShipActivities", "DVDCustomer_DVDShipActivities", "DVDCustomer", "DVDShipActivity"),
                },
                new EntityType("DVDShipActivity")
                {
                    new MemberProperty("Id", EdmDataTypes.Int32)
                    {
                        IsPrimaryKey = true
                    },
                    new MemberProperty("OrderDescription", EdmDataTypes.String()),
                    new MemberProperty("Title", EdmDataTypes.String()),
                    new MemberProperty("ShipTime", EdmDataTypes.DateTime()),
                    new MemberProperty("ReturnTime", EdmDataTypes.DateTime()),
                    new MemberProperty("ProblemReport", EdmDataTypes.String()),
                    new NavigationProperty("DVDCustomer", "DVDCustomer_DVDShipActivities", "DVDShipActivity", "DVDCustomer"),
                },
                new AssociationType("DVDCustomer_DVDShipActivities")
                {
                    new AssociationEnd("DVDCustomer", "DVDCustomer", EndMultiplicity.One),
                    new AssociationEnd("DVDShipActivity", "DVDShipActivity", EndMultiplicity.Many),
                },
                new AssociationType("Movies_Actors")
                {
                    new AssociationEnd("Movies", "Movie", EndMultiplicity.Many),
                    new AssociationEnd("Actors", "Actor", EndMultiplicity.Many),
                },
                new AssociationType("ActorMovieRating_Movie")
                {
                    new AssociationEnd("Movie", "Movie", EndMultiplicity.ZeroOne),
                    new AssociationEnd("ActorMovieRating", "ActorMovieRating", EndMultiplicity.Many),
                },
                new AssociationType("ActorMovieRating_Actor")
                {
                    new AssociationEnd("Actor", "Actor", EndMultiplicity.ZeroOne),
                    new AssociationEnd("ActorMovieRating", "ActorMovieRating", EndMultiplicity.Many),
                },
                new AssociationType("MovieRating_Movie")
                {
                    new AssociationEnd("MovieRating", "MovieRating", EndMultiplicity.Many),
                    new AssociationEnd("Movie", "Movie", EndMultiplicity.ZeroOne),
                },
                new Function("CheckoutFirstMovie")
                {
                    new ToggleBoolPropertyValueActionAnnotation()
                    {
                        SourceEntitySet = "Movie", ToggleProperty = "IsAwardWinner"
                    },
                    new ServiceOperationAnnotation()
                    {
                        BindingKind = OperationParameterBindingKind.Never, IsAction = true
                    }
                },
                new Function("PayCustomerBalance")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "BalancePaid", ReturnProperty = "DVDShipActivities"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction      = true,
                            EntitySetPath = "customer/DVDShipActivities",
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("customer", DataTypes.EntityType.WithDefinition("DVDCustomer")),
                    },

                    ReturnType = DataTypes.CollectionOfEntities("DVDShipActivity"),
                },
                new Function("AddToQueue")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "AddToQueueValue", ReturnProperty = "Id"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction = true,
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("movie", DataTypes.EntityType.WithDefinition("Movie")),
                    },

                    ReturnType = EdmDataTypes.Int32
                },
                new Function("UpVoteExecutiveProducer")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "Toggle", ReturnProperty = "FirstName"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction    = true,
                            BindingKind = OperationParameterBindingKind.Sometimes
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("executiveProducer", DataTypes.EntityType.WithDefinition("ExecutiveProducer")),
                    },

                    ReturnType = EdmDataTypes.String()
                },
                new Function("UpVoteProducer")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "Toggle", ReturnProperty = "FirstName"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction    = true,
                            BindingKind = OperationParameterBindingKind.Sometimes
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("producer", DataTypes.EntityType.WithDefinition("Producer")),
                    },

                    ReturnType = EdmDataTypes.String()
                },
                new Function("AddToQueue2")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "AddToQueueValue2", ReturnProperty = "Id"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction    = true,
                            BindingKind = OperationParameterBindingKind.Sometimes
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("movie", DataTypes.EntityType.WithDefinition("Movie")),
                    },

                    ReturnType = EdmDataTypes.Int32
                },
                new Function("AddToQueueThrowError")
                {
                    Annotations =
                    {
                        new ThrowDataServiceExceptionAnnotation()
                        {
                            ErrorStatusCode = 500, ErrorMessage = "Throwing error in AddToQueueThrowError function"
                        },
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "AddToQueueValue", ReturnProperty = "Id"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction = true,
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("movie", DataTypes.EntityType.WithDefinition("Movie")),
                    },

                    ReturnType = EdmDataTypes.Int32
                },

                new Function("MultiParameterFunction")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "AddToQueueValue", ReturnProperty = "Id"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction = true,
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("movie",    DataTypes.EntityType.WithDefinition("Movie")),
                        new FunctionParameter("author",   EdmDataTypes.String()),
                        new FunctionParameter("comments", DataTypes.CollectionType.WithElementDataType(EdmDataTypes.String())),
                    },

                    ReturnType = EdmDataTypes.Int32
                },
                //// Declaring an action in the Actor Entity that will have a name collision with the 'Age' property
                new Function("Age")
                {
                    Annotations =
                    {
                        new ToggleBoolPropertyValueActionAnnotation()
                        {
                            ToggleProperty = "IsAwardWinner", ReturnProperty = "FirstName"
                        },
                        new ServiceOperationAnnotation()
                        {
                            IsAction = true,
                        }
                    },

                    Parameters =
                    {
                        new FunctionParameter("actor", DataTypes.EntityType.WithDefinition("Actor")),
                    },

                    ReturnType = EdmDataTypes.String()
                }
            };

            this.AddServiceOperationsToModel(model);

            new ResolveReferencesFixup().Fixup(model);
            new ApplyDefaultNamespaceFixup("NetflixActions").Fixup(model);
            new AddDefaultContainerFixup().Fixup(model);

            // add MEST scenarios in the model
            if (this.DataProviderSettings.SupportsMest)
            {
                EntityContainer ec = model.EntityContainers.Single();
                EntityType      customerEntityType            = ec.EntitySets.Single(es => es.Name == "DVDCustomer").EntityType;
                EntitySet       instantWatchCustomerEntitySet = new EntitySet("InstantWatchCustomer", customerEntityType);
                ec.Add(instantWatchCustomerEntitySet);

                EntityType activityEntityType            = ec.EntitySets.Single(es => es.Name == "DVDShipActivity").EntityType;
                EntitySet  instantWatchActivityEntitySet = new EntitySet("InstantWatchActivity", activityEntityType);
                ec.Add(instantWatchActivityEntitySet);

                AssociationType at = model.Associations.Single(a => a.Name == "DVDCustomer_DVDShipActivities");
                ec.Add(new AssociationSet("InstantWatchCustomer_InstantWatchActivities", at)
                {
                    Ends =
                    {
                        new AssociationSetEnd(at.Ends[0], instantWatchCustomerEntitySet),
                        new AssociationSetEnd(at.Ends[1], instantWatchActivityEntitySet),
                    }
                });
            }

            // Only add these actions if its not using the model for call order tests
            if (!this.AdaptModelForCallOrderTests)
            {
                this.AddEntityTypeDrivenToggleActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "ActorMovieRating"));
                this.AddEntityTypeDrivenToggleActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "Movie"));
                this.AddEntityTypeDrivenToggleActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "Actor"));
                this.AddEntityTypeDrivenToggleActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "AllTypes"));

                if (this.DataProviderSettings.SupportsSpatial)
                {
                    this.AddEntityTypeDrivenToggleActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "AllSpatialTypes"));
                }

                this.AddIncrementIntegerPropertyActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "AllTypes"), "Int32Property");

                if (this.DataProviderSettings.SupportsSpatial)
                {
                    this.AddIncrementIntegerPropertyActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "AllSpatialTypes"), "Int32Property");
                }

                this.AddIncrementIntegerPropertyActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "Actor"), "Age");
                this.AddIncrementIntegerPropertyActions(model, model.EntityContainers.First().EntitySets.Single(es => es.Name == "Movie"), "LengthInMinutes");
            }

            // Add page size = 1 for all exposed entity sets in the model
            var movieEntitySet = model.EntityContainers.First().EntitySets.Single(es => es.Name == "Movie");

            movieEntitySet.Annotations.Add(new PageSizeAnnotation()
            {
                PageSize = 1
            });

            this.SetupBindingParameterCollectionTypeAnnotation(model);

            if (this.RemoveHigherVersionModelFeaturesExceptActionWithMultiValue)
            {
                new AddDefaultContainerFixup().Fixup(model);
                new SetDefaultDataServiceConfigurationBehaviors()
                {
                    MaxProtocolVersion = DataServiceProtocolVersion.V4
                }.Fixup(model);

                var functionsToSave = model.Functions.Where(f => f.IsAction() && f.ReturnType != null && f.Parameters.Count > 0);
                var functionToSave  = functionsToSave.Where(f => f.Parameters.Any(p => p.DataType is CollectionDataType && !(((CollectionDataType)p.DataType).ElementDataType is EntityDataType))).ToArray().FirstOrDefault();
                new RemoveHigherVersionFeaturesFixup(DataServiceProtocolVersion.V4).Fixup(model);

                model.Add(functionToSave);
            }

            // Remove streams from the model if this is being used for call order tests
            if (this.AdaptModelForCallOrderTests)
            {
                new RemoveNamedStreamsFixup().Fixup(model);
                model.EntityTypes.ForEach(et => et.Annotations.RemoveAll(a => a.GetType() == typeof(HasStreamAnnotation)));

                // Add Query Interceptors for all sets so they will be triggered when running via call order
                model.EntityContainers.Single().EntitySets.ForEach(es => es.Annotations.Add(new ConstantInterceptorAnnotation()
                {
                    FilterConstant = true
                }));
            }

            return(model);
        }