EF Feature CTP5

12/8/2010 12:51:00 AM By Felipe Pessoto

Com alguns dias de atraso, foi lançado o quinto e último CTP do Entity Framework Code First. A versão final é esperada para o final do primeiro trimestre de 2011. É importante resaltar os known issues:

  • Table & Column Mapping in the Fluent API
    We have done some work to make the mapping of classes/properties to tables/columns simpler and more intuitive in CTP5. We are still working to improve the quality of this new work, particularly around the mapping of inheritance hierarchies.
  • Pluggable Conventions 
    CTP5 includes a very early preview of this feature that is not complete and has not been extensively tested.
  • The new Validation feature is currently only supported when using Code First  


As novidades são:

 -DbContext:

  • T4 Templates for using DbContext/DbSet with Model First & Database First
  • Validation of objects on save 
    Validation is based on the use of Data Annotations and currently only supported in Code First
  • Change Tracker API 
    Allows you to access information and operations applicable to objects that are tracked by a DbContext
    • Original, Current & Store Values
    • State (i.e. Added, Unchanged, Modified, Deleted)
    • Explicit Load (i.e. load the contents of a navigation property from the database)
  • DbSet.Local exposes an ObservableCollection representing the local contents of the DbSet 
    This is particularly useful when performing databinding in WPF or WinForms
  • Support for No-Tracking Queries via the AsNoTracking extension method on IQueryable<T>
  • DbContext Configuration  
    Allows the following options to be configured for a DbContext instance;
    (Note: All of these are On by default)
    • Lazy Loading
    • Validate On Save
    • Auto Detect Changes
  • Raw SQL Query/Command 
    Allows raw SQL queries and commands to be executed via the SqlQuery & SqlCommand methods on DbContext.Database. The results can optionally be materialized into object instances that are tracked by the DbContext via the SqlQuery method on DbSet.
  • Improved concurrency conflict resolution 
    CTP5 provides better exception messages that allow access to the affected object instance and the ability to resolve the conflict using current, original and database values

 

-Code First:


  • Full data annotation support
    The full list of data annotations supported in CTP5 is;
    • KeyAttribute
    • StringLengthAttribute
    • MaxLengthAttribute
    • ConcurrencyCheckAttribute
    • RequiredAttribute
    • TimestampAttribute
    • ComplexTypeAttribute
    • ColumnAttribute 
      Placed on a property to specify the column name, ordinal & data type
    • TableAttribute 
      Placed on a class to specify the table name and schema
    • InversePropertyAttribute 
      Placed on a navigation property to specify the property that represents the other end of a relationship
    • ForeignKeyAttribute 
      Placed on a navigation property to specify the property that represents the foreign key of the relationship
    • DatabaseGeneratedAttribute 
      Placed on a property to specify how the database generates a value for the property (Identity, Computed or None)
    • NotMappedAttribute 
      Placed on a property or class to exclude it from the database
  • Fluent API Improvements
    • Simplified table and column mapping
    • Ability to ignore classes & properties
  • Pluggable Conventions 
    Based on the large amount of feedback requesting this feature we have included an early preview in CTP5. We still have some work to do on this feature but we wanted to give you the chance to provide feedback before we RTM. We’ll provide more details on this feature in the coming weeks.

 

Além disso algumas  foram feitas algumas alterações

  • New Assembly Name
    Our assembly name has changed to EntityFramework.dll
  • Better Code First to Existing Database Support 
    CTP5 removes the need to switch off Database Initializers when working with existing databases with Code First. If you map to an existing database that Code First did not create then it will just ‘trust you’
  • DbContext.ObjectContext has moved 
    Rather than being a protected member we have made the underlying ObjectContext available via an explicitly implemented interface, this allows external components to make use of the underlying context. Getting the context now looks like; ((IObjectContextAdapter)myContext).ObjectContext
  • Excluding EdmMetadata Table 
    If Code First is generating your database and you wish to exclude the EdmMetadata table, this is now done by removing a convention (note that you do no longer need to do this when mapping to an existing database).
  • Class Changes
  • CTP4 Name CTP5 Name
    Database System.Data.Entity.Database.DbDatabase
    RecreateDatabaseIfModelChanges System.Data.Entity.Database.DropCreateDatabaseIfModelChanges
    AlwaysRecreateDatabase System.Data.Entity.Database.DropCreateDatabaseAlways
    CreateDatabaseIfNotExists System.Data.Entity.Database.CreateDatabaseIfNotExists
    SqlConnectionFactory System.Data.Entity.Database.SqlConnectionFactory
    SqlCeConnectionFactory System.Data.Entity.Database.SqlCeConnectionFactory

Comments (0)