TopMenu

What's New in ADO.NET Entity Framework 4 and WCF Data Services 4?


There are a number of exciting features shipping in .NET Framework 4.0 and Visual Studio2010. In WCF (ADO.NET) Data Services a few such features are:
  • Data Binding: The data services client library for the .NET Framework 3.5 SP1 and Silverlight has been extended to support two-way data binding for WPF and Silverlight based applications.
  • Row Count: One scenario we heard a ton of feedback on after shipping version 1 of ADO.NET Data Services in the .NET Framework 3.5 SP1 is the ability for the a client of a data service to determine the total number of entities in a set without having to retrieve them all. To address this need, we have extended the data services addressing scheme to allow a client to obtain this type of information without having to download all the entities in a set.
  • Feed Customization (aka "Web Friendly Feeds"): A common ask we have received is to provide the ability to customize how entities are mapped into the various elements of an AtomPub feed. This feature does just that by providing a data service author declarative control over how the data service runtime maps the properties of an entity (e.g. a Customer, Order, etc) to the elements of a feed.
  • Server Driven Paging: This feature allows a service author to set per collection limits on the total number of entities returned for each request. For example, if you had a data service that exposes photos, you likely want to limit the total number of photos a single request to the service can retrieve because the total collection of photos may be very large. In addition to limiting the number of photos returned per request, the server provides the client a "next link" which is simply a URI specifying how to continue retrieving the rest of the entities in the collection not returned by the first request. For those familiar with AtomPub, this feature adds support for AtomPub <next ..> elements to the data service runtime.
  • Enhanced BLOB Support: This feature enhances the BLOB support provided in V1 to enable data services to stream arbitrarily large BLOBs, store binary content separate from its metadata, easily defer the loading of BLOB content when its metadata is requested, etc.
  • New "Data Service Provider" Interface for Custom Provider Writers: As the data services runtime has evolved, so has the number of ways people want to plug data into the data service framework. In V1, two methods (Entity Framework and arbitrary .NET classes) were supported to enable a data service to interact with various diverse data sources. To address another class of environments and data sources we are exploring a way to write a "custom" provider for those cases when the previous two provider models don't meet your needs.
  • Projections: The data services client library and server now supports projections both in the URI syntax and LINQ query syntax.
In the ADO.NET Entity Framework we listened to a great deal to customer feedback and responded with significant investments including:

  • Foreign Keys: Entity Framework 4 now includes a new type of associations (Foreign Key Associations) that allow you to have Foreign Key properties on your entities. Foreign Key Associations simplify some key scenarios such as data binding and can be included or excluded when using the model creation and update wizards. Independent Associations supported in .NET 3.5 remain as-is, but Foreign Key Associations become the default type of association going forward. Referential integrity constraints can now be created from the designer.
  • POCO Support: Fix-up of changes to navigation properties and FKs is now performed automatically on DetectChanges and SaveChanges. It is also now possible to declare collections as ISet<T> in POCO objects. When either ICollection<T> or ISet<T> is used, the default collection type materialized is HashSet<T>, which among other advantages does not allow duplicate entries.
  • Lazy Loading on by Default in new Models: When you create a new model in VS 2010, you get generated ObjectContext types that have lazy loading turned on by default (context.ContextOptions.LazyLoadingEnabled = true is placed in the constructor). This simplifies the default experience of working with objects. Of course, it is still possible to turn it off and do explicit and eager loading.
  • EntityDataSource support for Query Extenders and POCO: EntityDataSource now includes support for ASP.NET Query Extenders and POCO entities. Query Extenders are a new addition to ASP.NET that allow you to have more control over the data retrieval query of a Data Source, leveraging the LINQ capabilities of Entity Framework.
  • Support for Binary Keys: The Entity Framework now allows you to have binary property types (and varbinary storage columns) mapped as Entity Key/Foreign Key.
  • ObjectMaterialized event: It is now possible to write logic that is executed immediately after an object has been materialized. This event is raised after the scalar, complex and reference properties are populated (collections are filled afterwards).
  • Object Services API improvements to enable N-Tier and Self Tracking Entities:ObjectStateEntry.GetUpdatableOriginalValues method provides a access to an updatable data record that you can use to establish the original state of an entity at the property level.
  • Improvements to the generated SQL: Numerous simplifications and improvements of the SQL generated when querying using the Entity Framework have been done including removal of joins, better translation of certain functions, elimination of constants used for internal purposes, which results in removing of levels of nesting and others.
  • Navigation Property Management: Users can now delete and add navigation properties, enabling the creation of one-way associations.
  • Improved Database Generation: SQL CE support has been added. In addition, customization of database generation is significantly simpler now, with the ability to specify the DDL generation template to be used, as well as automatic discovery of installed database generation workflows and templates.
  • New Extensibility APIs: New APIs enable users to add custom properties to any object in the model and have those properties show up in the property sheet. In addition, other extension points allow for customization of models on load, save, and after the model creation and update wizards run.
  • Generation of Complex Types from Stored Procedures: When creating a function import from a function, the UI can now detect the columns returned from a stored procedure and create a corresponding complex type. In addition, existing complex types can be updated when a stored procedure definition changes.
  • Greatly Improved Facet Management: The designer can now distinguish between empty and blank values, and various property facet defaults are handled more cleanly and consistently.
  • LINQ to Entities improvements: Support for recognizing additional patterns in queries, simplification of EntityFunctions and SqlFunctions static classes and OrderBy is now lifted over filters and other operations. We are also actively working to address new asks such as concepts like model-defined functions in this release.

No comments:

Post a Comment