How to use complex type objects in Entity Framework 4
This article has been archived. It is offered "as is" and will no longer be updated.
This article describes an All-In-One Code Framework sample that is available for download. This code sample demonstrates how to use complex type, which is one of the new features of Entity Framework 4.0 (EF4). This code sample shows how to add complex type properties to entities, how to map complex type properties to table columns, and how to map a Function Import to a complex type.
Download informationTo download this code sample, click the following link:
Technical overviewComplex types are non-scalar properties of entity types that enable scalar properties to be organized within entities. Like entities, complex types consist of scalar properties or other complex type properties. Because complex types do not have keys, complex type objects cannot be managed by the Entity Framework apart from the parent object.
When the Entity Framework tools generate objects that represent entity types, these objects inherit from EntityObject. Likewise, objects generated for complex types inherit from ComplexObject. Both of these classes inherit from the StructuralObject base class. The scalar properties of complex type objects can be accessed like other scalar properties.
This sample demonstrates how to add complex Type properties to entities, how to map complex type properties to table columns, and how to map a Function Import to a complex type.
Note For more information about how to create the sample application and how to deploy the sample application, see the Readme.txt file that is included in the download package.
- ADO.NET Entity Framework
LanguagesThis code sample contains the following programming languages:
- This sample application was created by using Visual Studio 2010.
- You must attach the database file (EFDemoDB.mdf) that is included in the download package and then modify the connection string in the App.config file according to your database instance and login account.
- Entity Framework, Complex Type
What is All-In-One Code Framework?All-In-One Code Framework shows most Microsoft development techniques by using code samples in different programming languages. Each example is carefully selected, composed, and documented to show one common code scenario. For more information about All-In-One Code Framework, visit the following Web site:
How to find more All-In-One Code Framework samplesTo find more All-In-One Code Framework samples, you can simply click the following link:
For more information, visit the following Web sites:
Complex Type Objects (Entity Framework)
How to: Add a Complex Type Property to an Entity (Entity Data Model Tools)
How to: Create and Modify Complex Types (Entity Data Model Tools)
How to: Map Complex Type Properties to Table Columns (Entity Data Model Tools)
How to: Map a Function Import to a Complex Type (Entity Data Model Tools)
Article ID: 2127408 - Last Review: 12/12/2015 08:47:38 - Revision: 3.0
Microsoft Visual Studio 2010 Professional, Microsoft Visual Studio 2010 Ultimate
- kbnosurvey kbarchive KB2127408