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.
To download this code sample, click the following link:
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.
ADO.NET Entity Framework
This 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: http://1code.codeplex.com
How to find more All-In-One Code Framework samples