I thought it would be useful (at least to me!) to summarise the new stuff in Entity Framework 4 given it actually comes in 2 parts.
The list is a simplified and categorised version of this and this.
- Foreign Keys now added: EF 4 now includes a new type of associations (Foreign Key Associations) that allow you to have Foreign Key properties on your entities. They are the default although the EF v1 Independent Associations remain.
- Lazy Loading on by Default in new Models: Also name change from Beta 1. context.ContextOptions.LazyLoadingEnabled = true is placed in the constructor
- Support for Binary Keys: The EF now allows you to have binary property types (and varbinary storage columns) mapped as Entity Key / Foreign Key.
- ObjectMaterialized event: Can write logic that is executed immediately after an object has been materialized.
- Improved Database Generation: SQL CE support has been added plus customization of database generation is significantly simpler.
- More Improvements to the generated SQL
- LINQ to Entities improvements
- Improvements to POCO Support: Automatically fixes nav properties and FKs on DetectChanges and SaveChanges. Collections can also be declared as ISet<T>
- EntityDataSource support for Query Extenders and POCO: EntityDataSource now includes support for the new ASP.NET Query Extenders and POCO entities.
Self Tracking Entities
- 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.
- Works with Foreign Key associations: Including Fix-up logic has been tidied up to be aware of FKs.
- Support for Silverlight 3 via WCF
- Better Silverlight and WPF Databinding support: Generated entity types now implement INotifyPropertyChanged and use ObservableCollections
- Richer concurrency control support: Original values are preserved for all required properties according to their concurrency mode in the Entity Data Model.
- Fewer Round Trips: The approach for managing entities with dangling references has been reengineered to avoid unnecessary database round-trips.
- New and improved methods: AcceptChanges, StartTracking, StopTracking where added and the existing MarkAsX methods are now extension methods.
- Generated code improvements and refactoring: The ApplyChanges implementation has been moved to the Context template.
- Navigation Property Management: Users can now delete and add navigation properties, enabling the creation of one-way associations.
- New Extensibility APIs: New APIs enable custom code to run on model wizards etc.
- Auto Generation of Complex Types from Stored Procedures: Plus auto update when a stored procedure definition changes.
- Greatly Improved Facet Management in the Designer