Partilhar via


Customizing Objects

The ADO.NET Entity Framework provides tools to automatically generate an object layer based on the conceptual model. These data classes can be customized to varying degrees, depending on the requirements of your application. You can also use your own custom data classes together with your data model. This is useful when you upgrade data classes from an existing application to use the Entity Framework, or when you want more control of how data classes are created.

The Entity Framework enables you to use custom data classes with your data model without making any modifications to the data classes themselves, as long as the names of the entity types, complex types, and properties in the custom data classes match the names of the entity types, complex types, and properties in the conceptual model. This enables you to use "plain-old" CLR objects (POCO), such as domain objects, with your data model. For more information, see Working with POCO Entities.

If you worked with custom objects in the Entity Framework 3.5 SP1, you had the following options:

  • Extend the generated partial classes by using custom methods and properties in a separate source file.

  • Implement the following Entity Framework interfaces and apply EDM attributes that map the custom classes and properties to entities defined in the conceptual model:

  • Derive from the EntityObject type and apply EDM attributes that map the custom classes and properties to entities defined in the conceptual model.

In the Entity Framework version 4, implementing Entity Framework interfaces and deriving from the EntityObject type is supported, but we recommend that you use POCO classes or extend the generated partial classes.

In This Section

Defining Business Logic

Working with POCO Entities

Extending Entity Framework Generated Types

See Also

Concepts

Working with Objects