EntityFrameworkComplexTypesEFDesigner
Library
Documentation
Learn
Videos
SearchDatawithBing
Downloads
Articles
Books
Support
Handson Labs
Community
Sign in
Forums
Webcasts
Data Developer Center > Learn > Entity Framework > Get Started > Complex Types EF Designer
Note:When you build the conceptual model, warnings about unmapped entities and associations may appear in the Error List. You can ignore these warnings because
after you choose to generate the database from the model, the errors will go away.
https://msdn.microsoft.com/enus/data/jj680147.aspx
1/5
20/05/2015
EntityFrameworkComplexTypesEFDesigner
On the designer surface, select one or more properties excluding navigation properties of an entity, then rightclick and selectRefactor > Move to New
Complex Type.
A new complex type with the selected properties is added to the Model Browser. The complex type is given a default name.
A complex property of the newly created type replaces the selected properties. All property mappings are preserved.
A new complex type is added to the folder with a default name. You can now add properties to the type.
https://msdn.microsoft.com/enus/data/jj680147.aspx
2/5
20/05/2015
EntityFrameworkComplexTypesEFDesigner
Add an Existing Complex Type to an Entity and Map its Properties to Table Columns
1. Rightclick an entity, point toAdd New, and selectComplex Property.
A complex type property with a default name is added to the entity. A default type chosen from the existing complex types is assigned to the property.
2. Assign the desired type to the property in thePropertieswindow.
After adding a complex type property to an entity, you must map its properties to table columns.
3. Rightclick an entity type on the design surface or in theModel Browserand selectTable Mappings.
The table mappings are displayed in theMapping Detailswindow.
4. Expand theMaps to <Table Name>node.
AColumn Mappingsnode appears.
5. Expand theColumn Mappingsnode.
A list of all the columns in the table appears. The default properties if any to which the columns map are listed under theValue/Propertyheading.
6. Select the column you want to map, and then rightclick the correspondingValue/Propertyfield.
A dropdown list of all the scalar properties is displayed.
7. Select the appropriate property.
https://msdn.microsoft.com/enus/data/jj680147.aspx
3/5
20/05/2015
EntityFrameworkComplexTypesEFDesigner
Note:To delete a column mapping, select the column that you want to map, and then click theValue/Propertyfield. Then, select Delete from the dropdown list.
ClickOK.
The function import entry is created in the conceptual model.
https://msdn.microsoft.com/enus/data/jj680147.aspx
4/5
20/05/2015
EntityFrameworkComplexTypesEFDesigner
If necessary, change the column names to match the column names that are returned by the stored procedure that corresponds to the function import.
using(SchoolEntitiescontext=newSchoolEntities())
{
varcourses=
fromcincontext.OnsiteCourses
orderbyc.Details.Time
selectc
foreach(varcincourses)
{
Console.WriteLine("Time:"+c.Details.Time)
Console.WriteLine("Days:"+c.Details.Days)
Console.WriteLine("Location:"+c.Details.Location)
}
}
https://msdn.microsoft.com/enus/data/jj680147.aspx
5/5