August CTP of the Entity Framework released

Sorry for the dearth of blog posting folks, but now that the August CTP is out, it seems like I really ought to provide some more info on the features added in this CTP.  First, I'll point you to the official announcement which contains links to the download point for the framework, the first CTP of the designer (yeah!), the online docs and samples, etc.

 Now here's my short summary of each of the features listed in the announcement:

· Events to customize code generation

Events that fire during code generation whenever types or properties are generated. The event handlers can be used to customize the generated code. Of course there are other mechanisms like partial classes which can be used to add custom logic into the classes or IPOCO which can be used to author the classes altogether by hand rather than using code gen at all, but this mechanism does provide some extensibility points for more advanced code generation scenarios.

· Abstract types in EDM models

As the name implies, this makes it possible to declare types in an EDM model (csdl file) which are explicitly abstract—no entity instances can be created for these types, but types can be derived from them.

· Complex types

“Complex types” is the Entity Framework name for value properties which have more intricate structure than scalars. The canonical example is an Address type which contains several parts (street, city, state, etc.) Complex types are somewhat like entities except that they do not have any identity of their own (they are value types). This means that a complex type instance is always a part of some other enclosing entity—it can’t stand on its own, it doesn’t have relationships, etc. In this release, the mapping scenarios for complex types are significantly limited: inheritance is not supported, complex type properties cannot be null and they can only occur in single instances, not collections.

· <Using> support in metadata files

Models can be built from multiple separate CSDL files—somewhat like a “using” statement in a C# file which brings a namespace into the file or a #include statement in a C/C++ program except with greater validation than you get in the purely textual preprocessing of #include.

· Entity key serialization

In previous CTPs EntityKey objects were not serializable, now they are.

· Increased persistence ignorance in entity data classes

We are continuing down the path toward true POCO and persistence ignorance. To that end we have split the original IPOCO interface (IEntity) into two separate, more specific interfaces (IEntityWithKey and IEntityWithChangeTracker), we made IEntityWithKey optional (not implementing it has performance implications, but the scenario is supported), and many of the ObjectServices signatures have been modified to take instances of Object rather than IEntity which sets the stage for further progress here in future releases.

· Improved connection management in ObjectContext

In previous CTPs the underlying provider connection was opened when the ObjectContext was constructed and held open for the life of the context—this would create issues, for instance, with databases where licensing was based on the number of concurrently open connections since the connection might be held open for an extended period of time—even when the connection is not being used. The new model keeps the connection closed as much as possible while still appropriately dealing with transactions and avoiding promotion of those transactions from local to DTC where possible.

· Improved DataBinding usability

Now ObjectQuery<T> and EntityCollection<T> implement IListSource which makes databinding more automatic rather than requiring explicit calls to the ToBindingList() method. In fact, since the automatic mechanism is so much better, ToBindingList was removed.

· Metadata annotations

CSDL files can now include custom annotations which the framework ignores but can be useful for tools or other systems built around the EDM.

· Better support for span over LINQ to Entities queries

The span feature makes it possible to pre-fetch related entities. In previous CTPs span was specified through a property on ObjectQuery<T>, but in this CTP span has been changed to work as a builder method, Include, which makes it simpler to specify span rules in LINQ to Entities queries. Include can be called on the ObjectQuery used in the from clause of the LINQ query.

· Improvements to LINQ queries: additional canonical functions and automatic mapping from CLR functions to server functions

This means that more CLR functions are recognized and mapped to store functions in the generated SQL queries.

· A new event for extensibility of SaveChanges

The OnSavingChanges event fires at the beginning of the SaveChanges method making it possible to perform validation on entities which will be saved, etc.

· Polymorphic results from stored procedures

Stored procedures can that retrieve entity instances can now return polymorphic results rather than being restricted only to results of a single type.

The other major feature, of course, is that it works with Orcas Beta 2!

If you have any questions or feedback, please don't hesitate to send it along.