Geeks With Blogs

News

This blog has moved to ericnelson.wordpress.com

 Subscribe in a reader

Add to Google Reader or Homepage


Links
View my teams slideshare
These postings are provided "AS IS" with no warranties, and confer no rights.



IUpdateable has moved to ericnelson.wordpress.com Please visit http://ericnelson.wordpress.com

[This is the fourth in a series of posts on getting started with the new features in Entity Framework 4 based on the demos I did in my session at TechEd Europe in Berlin last week (Nov 2009).]

Complex Types make it easier to work with objects, allowing the grouping of related properties in Entities and the reuse of these groupings across Entities.

The first release of Entity Framework included Complex Type support but did not expose this capability through the Entity Data Model Designer. The good news is … it now does.

You can check out the MSDN documentation on using the ADO.NET Entity Data Model Designer with complex types:

In my earlier post on Model First I slipped in a complex type for Product.

image

Specifically I used the Refactor into New Complex Type option of the designer:

image

To take two properties of Product, Description and Price, and create a new Complex Type ProductDetails:

image

When I then went on to generate the database script, Entity Framework came up with the following physical schema to support my complex type, concatenating the property name Details with the original property names Description and Price:

image

 

The corresponding mapping is:

image

Nice and simple.

The other use of Complex Types is to map a Function Import to a Complex Type. This is worthy of its own post in the future – as this functionality dramatically simplifies working with stored procedures in Entity Framework 4.

Posted on Tuesday, November 24, 2009 12:46 PM .NET 4.0 , Data , Entity Framework , EF4 | Back to top


Comments on this post: Getting Started with Entity Framework 4 – Complex Types and Entities

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Eric Nelson | Powered by: GeeksWithBlogs.net