Freigeben über


Object-Entity Mapping Attributes (Entity Framework)

The following Entity Data Model (EDM) attributes must be applied to the appropriate namespace, class, and data properties:

Attribute Applies to: Definition

EdmComplexPropertyAttribute

Each complex type property that belongs to an entity type in the conceptual schema definition language (CSDL).

Indicates that the property maps to a complex type property.

EdmComplexTypeAttribute

Each class that maps to a complex type in the CSDL.

Indicates that the type is mapped to a complex type.

EdmEntityTypeAttribute

Each class that maps to an entity type in the CSDL.

Indicates that the class is mapped to an entity.

EdmRelationshipNavigationPropertyAttribute

Each property that is a navigation property.

Indicates that the property is a navigation property for the association that relates this type to another entity type or collection.

You must specify the name of the association for the RelationshipName property. You must also specify the role name of the targeted entity at the other end of the association for the TargetRoleName property.

EdmRelationshipAttribute

The assembly level; once for each association between types defined in the CSDL.

Indicates how two types are associated in an assembly. You must specify the following properties:

  • RelationshipName. The name of the association.

  • RelationshipNamespaceName. The name of the namespace for the association.

  • Role1Multiplicity. A value of RelationshipMultiplicity that indicates the multiplicity at the first end of the association, such as one or many.

  • Role1Name. The name of the role that the first entity represents in the association.

  • Role1Type. The type of the first entity in the association, as Type. The typeof operator (GetType in Visual Basic) is used to return the Type object for the entity.

  • Role2Multiplicity. A value of RelationshipMultiplicity that indicates the multiplicity at the other end of the association, such as one or many.

  • Role2Name. The name of the role that the other entity in the association represents.

  • Role2Type. The type of the entity at the other end of the association, as Type. The typeof operator (GetType in Visual Basic) is used to return the Type object for the entity.

EdmScalarPropertyAttribute

Each scalar property of an entity or complex type in the CSDL.

Indicates that the property maps to a scalar property. If the property is the object's key, set the EntityKeyProperty property to true.

EdmSchemaAttribute

Each assembly that contains classes that map to an EDM.

Indicates that the assembly has data classes that are mapped to EDM types.

For more information, see How to: Map Custom Objects to Entities (Entity Framework).

See Also

Concepts

Customizing Objects (Entity Framework)