In many of the new improvements, Visual Studio 2010 introduced the Long-awaited Entity Framework 4.0 and WCF Data Services 4.0 (formerly known as ado.net Data Services), which combined to simplify the way you build data models, work with data, and generate data.
The Entity Framework 4.0 (EF 4.0) is dedicated to enabling and simplifying two major scenarios: domain-centric application development and traditional data-centric "data-based form design." It introduces features such as model priority development, which allows you to create models and generate custom T-SQL for you, support for persistent transparency, foreign keys, deferred loading, and custom code generation for entities.
WCF Data Services 4.0 is dedicated to updating Open Data Protocol (odata.org) and its new features, including bidirectional data binding, row count, server-driven paging for Windows presentation Foundation (WPF) and Silverlight , enhanced binary large object support, and support for projections.
I will use a simple blog application (myblog) to explore new features in the EF and WCF data Services and how they work together to simplify the way in which data models are built and data is used. This sample application will contain a asp.net Web application that provides a read-only view of the blog post, and a Silverlight blog Administrator Client that allows the blog owner to edit articles. At the beginning of the application, I will first create an Entity Data Model (EDM) using the model, and then build the database and the code to interact with the database. This sample will also use the Ado.net Data Service update for Silverlight 3 CTP 3.
Getting Started with EF 4.0
I'll explore the ASP.net Web application project first. To start using EF, I use the Add New Item wizard to add a ado.net EDM and select an empty model that I also call Blogmodel. By right-clicking the empty designer surface and selecting properties, you can see the default entity container name, which is blogmodelcontainer in this example. First, I'll change the name to Blogcontext, and then I'll create the model.
MyBlog requires three entities, I name them Blog, Post and Tag, as shown in Figure 1. To create these entities, I drag an entity from the toolbox to the design surface, and then right-click and select Properties to edit the entity properties. On each of these entities, I will also need some scalar properties (right-click the entity and choose Add | Scalar property ").
Figure 1 Blog, Post and Tag entities and associated property settings