Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Core.dll Namespace: Microsoft.OData.Mcp.Core.Models Inheritance: System.Object

Syntax

Microsoft.OData.Mcp.Core.Models.EdmModel

Summary

Represents a complete OData Entity Data Model (EDM).

Remarks

The EDM defines the structure of data exposed by an OData service, including entity types, complex types, entity containers, and their relationships. This class serves as the root model that contains all metadata necessary to understand and interact with an OData service.

Constructors

.ctor

Initializes a new instance of the EdmModel class.

Syntax

public EdmModel()

.ctor

Initializes a new instance of the EdmModel class with the specified version.

Syntax

public EdmModel(string version)

Parameters

NameTypeDescription
versionstringThe version of the EDM.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when version is null or whitespace.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Actions

Gets or sets the actions defined in this model.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmAction> Actions { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmAction> A collection of actions that can be invoked on the service.

Remarks

Actions are operations that may have side effects and are used to modify data or perform operations that cannot be expressed through standard CRUD operations.

AllEntitySets

Gets all entity sets from all entity containers.

Syntax

public System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Models.EdmEntitySet> AllEntitySets { get; }

Property Value

Type: System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Models.EdmEntitySet> A flattened collection of all entity sets in the model.

AllSingletons

Gets all singletons from all entity containers.

Syntax

public System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Models.EdmSingleton> AllSingletons { get; }

Property Value

Type: System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Models.EdmSingleton> A flattened collection of all singletons in the model.

Annotations

Gets or sets the annotations for this model.

Syntax

public System.Collections.Generic.Dictionary<string, object> Annotations { get; set; }

Property Value

Type: System.Collections.Generic.Dictionary<string, object> A dictionary of annotations that provide additional metadata about the model.

Remarks

Annotations can be used to specify additional behaviors, constraints, or metadata that are not captured by the standard OData model elements.

ComplexTypes

Gets or sets the complex types defined in this model.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmComplexType> ComplexTypes { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmComplexType> A collection of complex types that define reusable structured data elements.

Remarks

Complex types are structured types without keys that can be used as property types in entity types or other complex types.

EntityContainer

Gets the primary entity container for this model (alias for PrimaryContainer).

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityContainer EntityContainer { get; }

Property Value

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityContainer? The first entity container, or null if no containers are defined.

EntityContainers

Gets or sets the entity containers defined in this model.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmEntityContainer> EntityContainers { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmEntityContainer> A collection of entity containers that define the service interface.

Remarks

Entity containers define the addressable resources in the OData service. Typically, there is one primary entity container per service.

EntityTypes

Gets or sets the entity types defined in this model.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmEntityType> EntityTypes { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmEntityType> A collection of entity types that define the structure of entities in the service.

Remarks

Entity types are the primary structural elements in the EDM, defining the properties and relationships that make up the data model.

Functions

Gets or sets the functions defined in this model.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmFunction> Functions { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmFunction> A collection of functions that can be called on the service.

Remarks

Functions are operations that can be called to retrieve data or perform calculations. They are side-effect free and can be composed with other query operations.

HasComplexTypes

Gets a value indicating whether this model has any complex types.

Syntax

public bool HasComplexTypes { get; }

Property Value

Type: bool true if the model has complex types; otherwise, false.

HasEntityContainers

Gets a value indicating whether this model has any entity containers.

Syntax

public bool HasEntityContainers { get; }

Property Value

Type: bool true if the model has entity containers; otherwise, false.

HasEntityTypes

Gets a value indicating whether this model has any entity types.

Syntax

public bool HasEntityTypes { get; }

Property Value

Type: bool true if the model has entity types; otherwise, false.

Namespaces

Gets or sets the namespaces used in this model.

Syntax

public System.Collections.Generic.List<string> Namespaces { get; set; }

Property Value

Type: System.Collections.Generic.List<string> A collection of namespace strings that organize the types in the model.

Remarks

Namespaces provide organizational structure and help avoid naming conflicts between types from different sources.

PrimaryContainer

Gets the primary entity container for this model.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityContainer PrimaryContainer { get; }

Property Value

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityContainer? The first entity container, or null if no containers are defined.

Remarks

Most OData services have a single entity container that serves as the primary interface. This property provides convenient access to that container.

Version

Gets or sets the version of the EDM.

Syntax

public string Version { get; set; }

Property Value

Type: string The version string (e.g., “4.0”, “4.01”).

Remarks

This indicates which version of the OData standard the model conforms to. Different versions have different capabilities and syntax.

Methods

AddAnnotation

Adds an annotation to this model.

Syntax

public void AddAnnotation(string term, object value)

Parameters

NameTypeDescription
termstringThe annotation term.
valueobjectThe annotation value.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when term is null or whitespace.

AddComplexType

Adds a complex type to the model.

Syntax

public void AddComplexType(Microsoft.OData.Mcp.Core.Models.EdmComplexType complexType)

Parameters

NameTypeDescription
complexTypeMicrosoft.OData.Mcp.Core.Models.EdmComplexTypeThe complex type to add.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when complexType is null.
InvalidOperationExceptionThrown when a complex type with the same full name already exists.

AddEntityContainer

Adds an entity container to the model.

Syntax

public void AddEntityContainer(Microsoft.OData.Mcp.Core.Models.EdmEntityContainer entityContainer)

Parameters

NameTypeDescription
entityContainerMicrosoft.OData.Mcp.Core.Models.EdmEntityContainerThe entity container to add.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when entityContainer is null.
InvalidOperationExceptionThrown when an entity container with the same full name already exists.

AddEntityType

Adds an entity type to the model.

Syntax

public void AddEntityType(Microsoft.OData.Mcp.Core.Models.EdmEntityType entityType)

Parameters

NameTypeDescription
entityTypeMicrosoft.OData.Mcp.Core.Models.EdmEntityTypeThe entity type to add.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when entityType is null.
InvalidOperationExceptionThrown when an entity type with the same full name already exists.

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetAnnotation

Gets an annotation value by term.

Syntax

public T GetAnnotation<T>(string term)

Parameters

NameTypeDescription
termstringThe annotation term.

Returns

Type: T? The annotation value, or the default value of T if not found.

Type Parameters

  • T - The type of the annotation value.

GetComplexType

Gets a complex type by its fully qualified name.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmComplexType GetComplexType(string fullName)

Parameters

NameTypeDescription
fullNamestringThe fully qualified name of the complex type (namespace.name).

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmComplexType? The complex type with the specified name, or null if not found.

GetComplexType

Gets a complex type by name and namespace.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmComplexType GetComplexType(string name, string namespace)

Parameters

NameTypeDescription
namestringThe name of the complex type.
namespacestringThe namespace of the complex type.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmComplexType? The complex type with the specified name and namespace, or null if not found.

GetEntityContainer

Gets an entity container by its fully qualified name.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityContainer GetEntityContainer(string fullName)

Parameters

NameTypeDescription
fullNamestringThe fully qualified name of the entity container (namespace.name).

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityContainer? The entity container with the specified name, or null if not found.

GetEntityContainer

Gets an entity container by name and namespace.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityContainer GetEntityContainer(string name, string namespace)

Parameters

NameTypeDescription
namestringThe name of the entity container.
namespacestringThe namespace of the entity container.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityContainer? The entity container with the specified name and namespace, or null if not found.

GetEntitySet

Gets an entity set by name from any entity container.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntitySet GetEntitySet(string entitySetName)

Parameters

NameTypeDescription
entitySetNamestringThe name of the entity set.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmEntitySet? The entity set with the specified name, or null if not found.

GetEntityType

Gets an entity type by its fully qualified name.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityType GetEntityType(string fullName)

Parameters

NameTypeDescription
fullNamestringThe fully qualified name of the entity type (namespace.name).

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityType? The entity type with the specified name, or null if not found.

GetEntityType

Gets an entity type by name and namespace.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmEntityType GetEntityType(string name, string namespace)

Parameters

NameTypeDescription
namestringThe name of the entity type.
namespacestringThe namespace of the entity type.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmEntityType? The entity type with the specified name and namespace, or null if not found.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetSingleton

Gets a singleton by name from any entity container.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmSingleton GetSingleton(string singletonName)

Parameters

NameTypeDescription
singletonNamestringThe name of the singleton.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmSingleton? The singleton with the specified name, or null if not found.

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Override

Returns a string representation of the model.

Syntax

public override string ToString()

Returns

Type: string A summary of the model contents.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the model for consistency and completeness.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate()

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of validation errors, or an empty collection if the model is valid.