iJustWantToProgram
iJustWantToProgram

Reputation: 76

How to change the metadata EntityContainer from "Default" in JayStack odata-v4-server

I'd like to set my own EntityContainer name other than the default 'Default' viewable in the XML $metadata schema.

I'm aware we can define our own Schema's using the odata-v4-metadata package, but this would mean the metadata would be returned as a JSON file instead of XML. I'm using a proxy generation script on the metadata file which depends on it being returned as XML.

You can see the tags which hold the "Products" EntitySets is called "Default". I'd like to change this if possible, without resorting to using a JSON schema.


    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
    <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Northwind">
    <EntityType Name="Product">
    <Key>
    <PropertyRef Name="_id"/>
    </Key>
    <Property Name="_id" Type="Edm.String" Nullable="false">
    <Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
    </Property>
    </EntityType>
    <EntityContainer Name="Default">
    <EntitySet Name="Products" EntityType="Northwind.Product"/>
    </EntityContainer>
    </Schema>
    </edmx:DataServices>
    </edmx:Edmx>

Upvotes: 0

Views: 340

Answers (1)

iJustWantToProgram
iJustWantToProgram

Reputation: 76

Place the following annotation:

    @odata.container("MyContainerName")

Above all classes you want to contain under the container "MyContainerName"

Upvotes: 0

Related Questions