Chapter 19. Using Your Own Custom Classes
In Chapter 10, you learned how to extend code-generated entity classes using partial classes and methods. However, this still may not provide enough extensibility for you to insert your own business logic. You may have an existing application with existing classes in which you would like to take advantage of the Entity Data Model (EDM) and the Entity Framework APIs. You may feel too limited by the classes that the EDM Designer generates from the model, and prefer to write your own classes to have true business objects that can integrate into the framework. You may even want to have classes that leverage the Entity Framework, but are not bound to it.
You can create custom classes in two ways. The first is to have your
objects inherit from EntityObject
. This
brings along everything you need to have your class integrate with Object
Services. The second method is to implement some key interfaces that will
allow your objects to take advantage of the state management and
relationship management features of Object Services.
In this chapter, you’re going to get a little break from the BreakAway model. The examples here will be against a modified version of Microsoft’s sample database, AdventureWorksLT, which is based on the imaginary AdventureWorks Cycles company. The database contains information for tracking customers, orders, and products. The SQL script for creating this modified version of the database, AdventureWorksSuperLT, is available on ...
Get Programming Entity Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.