Up DevForce
DevForce Resource Center » Getting started » DevForce » Migrating from DevForce 2010

Migrating from DevForce 2010

Last modified on January 16, 2013 22:11

This quick start guide summarizes the major changes when moving from DevForce 2010 to DevForce 2012.  For more detailed information, see the Migration Details topic.


NuGet

Like Microsoft's Entity Framework, DevForce 2012 has made the leap to NuGet. Instead of running a global DevForce installer, you now use NuGet to add a DevForce package to your project. NuGet will resolve all dependencies and automatically adds all the libraries and references that you'll need. For more details, see Installing DevForce 2012.

Asynchronous patterns

DevForce 2012 introduces the use of the Task-based Asynchronous Pattern (TAP). Many of you will have heard of this as being able to use the await keyword, which makes asynchronous method calls feel synchronous when you're writing code. So, instead of writing callbacks, lambda expressions, or coroutines, you now use await. To illustrate the difference, here's an example.

Using a lambda expression in DevForce 2010:

C#
 void MainPage_Loaded(object sender, RoutedEventArgs e) {
    var mgr = new NorthwindIBEntities();
    mgr.Employees.ExecuteAsync(op => {
      var emps = op.Results;
    });
    ...
  }

Using await in DevForce 2012:

C#
  async void MainPage_Loaded(object sender, RoutedEventArgs e) {
    var mgr = new NorthwindIBEntities();
    var emps = await mgr.Employees.ExecuteAsync();
    ...
  }

Remember to add the async keyword to the method signature! Otherwise you'll get a compile-time error.

Error handling is also more convenient with await. Instead of checking each operation to see if there was an error, you can perform multiple asynchronous tasks inside a single try / catch block. This makes code easier to read and removes a lot of redundant error handling code. 

If you wish to continue using the DevForce 2010 query methods or coroutines, see "DevForce 2010 Backward Compatibility" below.

QueryResult and EntityQueryOperation

Because the new asynchronous queries return results directly, they no longer return an EntityQueryOperation. If you'd like additional information about a query result, you should call TryExecuteQuery or TryExecuteQueryAsync. The QueryResult has the information which used to be on the EntityQueryOperation (like WasFetched, ChangedEntities, etc).

See Query asynchronously to learn more about queries, QueryResults, Tasks, and exception handling.

SaveResult

The SaveChanges / SaveChangesAsync API has also changed. A SaveResult is not returned by default. To obtain a SaveResult, call TrySaveChanges or TrySaveChangesAsync.

See Perform a save to learn more about the Save API.

Partial saves

Partial saves are no longer supported. A partial save is the ability to save a specific subset of the entities in cache. We have long advised against using this feature which is rarely needed in practice. We found over the years that developers tended to omit an essential related entity by accident with consequent failures of data integrity.

We have removed partial saves from DevForce 2012, hoping to steer developers away from trouble. Developers should consider implementing a Unit of Work pattern instead.

If you must perform partial saves, you can still achieve this effect by importing the selected entities into a separate EntityManager and calling SaveChanges on that manager. If there is sufficient demand, we could add partial saves to the Compatibility Assembly (see below). Let us know.

DevForce 2010 backward compatibility

If you would like to perform the migration to DevForce 2012 in phases, you can still access most of the old DevForce 2010 API by using NuGet to install the "DevForce 2012 Compatibility Pack". This adds a reference to IdeaBlade.EntityModel.Compat (or IdeaBlade.EntityModel.Compat.SL). See Using the DevForce 2012 Compatibility Pack for more information.

Cocktail 2010 backward compatibility

Cocktail also has a compatibility pack to support your migration. See Migrating from Cocktail v1.0.x for more information.

Licensing

All customers who have active DevForce 2010 subscriptions will be able to upgrade to DevForce 2012 for free. Just enter your existing DevForce 2010 key when asked during installation

Other breaking changes

Classes/methods marked obsolete or "for internal use only" in DevForce 2010 have been removed in DevForce 2012 including:

  • Login and Logout have been moved to the Authenticator  class.
  • The EntityQueryPagedCollectionView and ObjectDataSource have been removed and replaced by the EntityQueryPager .  Source code for the EntityQueryPagedCollectionView and ObjectDataSource is available on github.
  • The DefaultManager property has been removed. You should new one instead and store it in your class or repository.
  • The Notification Service ("Push") is not available. SignalR and the Windows Azure Service Bus are good alternatives.

If you are using any obsolete classes/methods, consider moving to the current API in DevForce 2010 before migrating to DevForce 2012. For a more comprehensive list of changes, please see the release notes.

Created by DevForce on September 06, 2012 16:05

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade