How to use complex type objects in Entity Framework 4

Article ID: 2127408 - View products that this article applies to.
Expand all | Collapse all

On This Page

INTRODUCTION

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.

Difficulty level

Collapse this imageExpand this image
2160968

Download information

To download this code sample, click the following link:

  


Technical overview

Complex 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.

Technology category

  • ADO.NET Entity Framework

Languages

This code sample contains the following programming languages:

Collapse this tableExpand this table
LanguageProject Name
Visual C#CSEFComplexType
Visual Basic.NETVBEFComplexType

Prerequisites

  • 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.

Tags

  • Entity Framework, Complex Type

MORE INFORMATION

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:
http://1code.codeplex.com

How to find more All-In-One Code Framework samples

To find more All-In-One Code Framework samples, you can simply click the following link:
http://support.microsoft.com/gp/gp_kbcodefx

REFERENCES

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)

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2127408 - Last Review: September 28, 2010 - Revision: 3.0
APPLIES TO
  • Microsoft Visual Studio 2010 Professional
  • Microsoft Visual Studio 2010 Ultimate
Keywords: 
KB2127408

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com